mattbaker/Reactive.js — pull request #5 by pvande (2013-04-20 21:45:25+00:00)
Title: Adding support for property lookup and assignments.

Example:

``` javascript
var obj = $R.state({ a: 123 });

// Bindings to specific properties can be easily created.
var obj_a = obj.property('a');
var double = $R(function(x) { return x * 2 }).bindTo(obj_a);
double(); // => 246

// Those bindings react to changes in the underlying object.
obj({ a: 100 });
double(); // => 200

// They may also be used to set the property values directly...
obj_a(10);
double(); // => 20
obj(); // => { a: 10 }

// ... without disrupting existing references to the object.
var hash = obj(); // => { a: 10 }
obj_a(12);
obj(); // => { a: 12 }
hash; // => { a: 10 }

// Property lookups may also be chained, and update appropriately.
var obj_a_b = a.property('b')
double.bindTo(obj_a_b);

obj({ a: { b: 12 }});
double(); // => 24

obj_a({ b: 20 });
double(); // => 40

obj_a_b(30);
double(); // => 60
```

Possible improvements:
* Property lookups might benefit from a chained lookup shorthand.
* e.g. `obj.property('a', 'b')` or `obj.property('a.b')`
* Property updates currently perform only a shallow clone; a deep clone may be warranted.