Skip to content

Chain React and AddProperties

Choose a tag to compare

@curran curran released this 13 Apr 15:03
· 141 commits to master since this release

Now the call to model() for setting up reactive functions returns the model, so you can chain calls to it.

Here's a new test that shows this feature:

it("Should chain react.", function (){
  var model = ReactiveModel()
    .addPublicProperty("a", 5)
    ({
      b: [function (a){
        return a + 1;
      }, "a"]
    });

  ReactiveModel.digest();

  assert.equal(model.b(), 6);
});

Also, there is an alternative way to add properties using object literals:

var model = ReactiveModel()
  .addPublicProperties({
    x: 5,
    y: 10
  });
var model = ReactiveModel()
  .addProperties({
    x: 5,
    y: 10
  });