Skip to content

Major Facelift

Compare
Choose a tag to compare
@curran curran released this 13 Apr 16:52
· 133 commits to master since this release

This release introduces new syntax for defining reactive properties. It also adds a nice way to define reactive functions with side effects but no output properties (e.g. DOM manipulation).

Here are some examples of the new syntax from the tests. For comparison with the old syntax see #14.

my("fullName", function (firstName, lastName){
  return firstName + " " + lastName;
}, "firstName, lastName");

The invocation now returns the model, so is chainable.

var my = ReactiveModel()
  .addPublicProperty("a", 5)
  ("b", function (a){
    return a + 1;
  }, "a");
var my = ReactiveModel()
  .addPublicProperty("a", 0)
  ("b", increment, "a")
  ("c", increment, "b");

It almost starts to feel like Lisp.

my
  ("b", increment, "a")
  ("d", increment, "c")
  ("e", add, "b, d");

New feature - reactive functions with no output properties (e.g. DOM manipulation).

my(function (a){
  sideEffect = a + 1;
}, "a");

If you appreciate my Open Source work, please consider supporting it on Patreon.