arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

Typo in set() example #99

Closed wchaering closed 7 years ago

arqex commented 7 years ago

Thanks for the PR @wchaering

But it's not a typo, it's something that's not well documented. The set method for objects accepts both inputs, and they are equivalent:

var updated = state.set( 'e', 4 );
var updated = state.set({'e': 4});

The first one is really useful for setting as key the value of another variable, for example:

var key = fullfillCondition ? 'foo' : 'bar';
state.set( key, 1 );
arqex commented 7 years ago

I'll add the second set form to the documentation for the next release.