Meteor Reactive Extra package
This is a Meteor package containing reactive classes. These classes can be used within Meteor to easily create reactive objects, dictionaries and arrays.
Install
Meteorite
Using meteorite do the following:
mrt add reactive-extra
Other
If you don't like using meteorite create the folder packages/reactive-extra/
and can copy the packages.js
and lib/
to it.
ReactiveObject
A reactive object implementation. Checkout the api docs
Usage
1var obj = new ReactiveObject({'foo':'1'}); 2obj.defineProperty('bar', 2); 3 4obj.foo = '2'; 5obj.undefineProperty('foo'); // Don't use 'delete obj.foo' it will give strange results
ReactiveDictionary
A reactive dictionary implementation. Checkout the api docs
Usage
1var obj = new ReactiveDictionary({'foo':'1'}); 2obj.add('bar', 2); 3obj.count() 4obj.foo = '2' 5obj.remove('foo'); // Don't use 'delete obj.foo' it will give strange results 6obj.clear();
ReactiveArray
A reactive array implementation. Checkout the api docs.
Usage
1var arr = new ReactiveArray(1,2,3,4); 2console.log arr.length 3arr.map(function(v) { 4 return v+1 5}).toArray(); 6 7// Be aware that using 'arr[9] = "a"' won't work correctly 8// A work around is to use 'arr.length = 10' and then do 'arr[9] = "a"'
ReactiveList
A reactive list implementation based on ReactiveArray. This implementation has a custom handlebars each helper extension. Checkout the api docs.
Cake
The current cake
commands require the wrench module, on windows the which module is also required.
cake build
This command will compile the files in src/
to lib/
.
cake example
This command will compile the files in src/
to lib/
, after which it will copy packages.js
and lib/
to example/packages/reactive-extra
.
cake docs
This command will generate the api docs in docs/
.
To get it working make sure you have docco installed.
Todo
- Write a real example not just a placeholder for tests
- Create Harmony Proxy versions of the classes
- Add
observe
and/orobserveChanges
methods when possible - Add more test where necessary