Evented object and array operations with the events library of your choice.
Evented object and array operations with the events library of your choice. Or a Model class.
This is a work in progress and I don't expect you to use this at all.
This little library should fit modular, diy MV* architectures where:
- Plain classes for models and plain arrays for collections just suffice.
- You're already working with an EventeEmitter library in your project and don't want every other libray you use having its own implementation of pub/sub.
- You want to listen for changes on regular and/or custom operations.
npm install empty
- Write API docs.
- Write example.
You need an external EventEmitter library. Require it and require Empty.
var Empty = require'empty';var EventEmitter3 = require'eventemitter3';
Empty.configure with the EventEmitter library as 'events' in a hash:
Make an instance,
new is optional. Pass in your actual model object.
var collection = 1 2 3 4;
Use it like this:
collectionon'push'console.log'pushed ' + elem + ' to numbers collection';;collectionpush5;> 5> 'pushed 5 to numbers collection'collectionoriginlength;> 5
All kind of feedback is very welcome.