Closed curran closed 8 years ago
Part of reactive-model 1.0 https://github.com/datavis-tech/reactive-model/issues/31
Should not be named bind
as there is already Function.prototype.bind()
Maybe it could look like this:
# ReactiveModel.link(model1, propertyName1, model2, propertyName2[, twoWay])
var link1 = ReactiveModel.link(modelA, "foo", modelB, "bar");
link1.destroy();
var link2 = ReactiveModel.link(modelA, "a", modelB, "b", true);
link2.destroy();
Better yet, no need to reference the models actually:
# ReactiveModel.link(propertyA, propertyB[, twoWay])
var link1 = ReactiveModel.link(modelA.foo, modelB.bar);
link1.destroy();
var link2 = ReactiveModel.link(modelA.a, modelB.b, true);
link2.destroy();
Perhaps this could be pushed down to reactive-function and simply exposed in reactive-model.
ReactiveFunction.link
as ReactiveModel.link
It turns out that bidirectional data binding was never working correctly. The test was bad. It also seems tricky to implement.
Leaving out two-way binding for now.
Based on this https://github.com/datavis-tech/reactive-function/blob/master/test.js#L379
Should support unidirectional as well as bidirectional