-
Notifications
You must be signed in to change notification settings - Fork 0
Array Manager
Malexion edited this page Nov 7, 2016
·
2 revisions
-
[options]
[Optional] option params and initial array.
Attempt at a multipurpose array manager for aurelia repeat.for bindings.
var manager = new __.lib.ArrayManager({
array: [
{ name: 'foo', income: 1000000 },
{ name: 'bar', income: 32460 },
{ name: 'sally', income: 0 },
{ name: 'jack', income: 50000 }
],
multiselect: true,
debounce: 0 // only for demo normally this has a default of 50 and prevents recalculation spam
});
console.log(manager.array); // bind this into the repeat.for
manager.filter(x => x < 500);
manager.add({ name: 'jill', income: -20 });
console.log(manager.array);
manager.map(x => x.name);
console.log(manager.array);
manager.filter(); // clears filter
manager.map(); // clears mapping
console.log(manager.array);
manager.select( __.first(manager.array, { limit: 3 }) );
console.log(manager.array);
console.log(manager.selection);
manager.unselect( __.first(manager.array, { limit: 3 }) );