* Bind a property to an object's field * 将属性绑定到对象的字段
(
source: IObservableProperty<T[K]>,
target: T,
key: K
)
| 285 | * 将属性绑定到对象的字段 |
| 286 | */ |
| 287 | public bind<T, K extends keyof T>( |
| 288 | source: IObservableProperty<T[K]>, |
| 289 | target: T, |
| 290 | key: K |
| 291 | ): this { |
| 292 | target[key] = source.value; |
| 293 | this._subscriptions.push( |
| 294 | source.subscribe((newValue) => { |
| 295 | target[key] = newValue; |
| 296 | }) |
| 297 | ); |
| 298 | return this; |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * Two-way bind between properties |