MCPcopy Create free account
hub / github.com/esengine/esengine / bind

Method bind

packages/fairygui/src/binding/PropertyBinding.ts:287–299  ·  view source on GitHub ↗

* Bind a property to an object's field * 将属性绑定到对象的字段

(
        source: IObservableProperty<T[K]>,
        target: T,
        key: K
    )

Source from the content-addressed store, hash-verified

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

Callers 1

initMethod · 0.45

Calls 2

pushMethod · 0.65
subscribeMethod · 0.65

Tested by

no test coverage detected