1
0
Fork 0
forked from 0x2620/oxjs

Ox.api: add update method (index, item); Ox.List: when initialized with array of items, update api when changing an item value

This commit is contained in:
rolux 2014-04-30 13:26:56 +02:00
commit 777fbc2a37
2 changed files with 19 additions and 15 deletions

View file

@ -303,6 +303,17 @@ Ox.api = function(items, options) {
callback && callback(result);
return result;
},
ret = Ox.extend(
api.cache ? Ox.cache(fn, {async: true}) : fn,
{
update: function(index, item) {
items[index] = item;
api.cache && ret.clear();
sortBy.clear();
return items;
}
}
),
sortBy = Ox.cache(function sortBy(array, by, map, query) {
return Ox.sortBy(array, by, map);
}, {
@ -423,7 +434,7 @@ Ox.api = function(items, options) {
return match;
}
return api.cache ? Ox.cache(fn, {async: true}) : fn;
return ret;
};