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:
parent
ef5a51d6bc
commit
777fbc2a37
2 changed files with 19 additions and 15 deletions
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue