filter-observable-store
v0.0.2
Published
Filter down an observable-store
Downloads
3
Readme
Filter-observable-store
Filter down an observable store https://github.com/flams/observable-store.
A filtered observable-store will:
- Return a
count
of items that match the filter - Only
loop
over items that match the filter - Only trigger events on items that match the filter
Installation
npm install filter-observable-store
How to use
var Store = require("observable-store");
var Filter = require("filter-observable-store");
var store = new Store([5, 10, 15]);
// Create a new filter around an existing store
var filter = new Filter(store);
// Set a filter function
filter.setFilter(function (value) {
return value >= 10;
}, scope);
// Get filtered count:
filter.count(); // 2
// Loop over filtered items
filter.loop(function (value) {
// value... 10, 15...
});
// See if an item is in the filtered model
filter.has(5); // false
filter.has(10); // true
// Clear filter
filter.clearFilter();
Changelog
0.0.2 - 6 APR 2015
- Add filtered has()
0.0.1 - 5 APR 2015
- first release
License:
MIT