add val api

pull/1/head
ansuz 7 years ago
parent ac718b6dfa
commit 56514d7e17

@ -25,6 +25,16 @@ define([
} }
*/ */
var val = function (proxy, id, k, v) {
var el = proxy.data[id];
if (!el) {
throw new Error('expected an element');
}
if (typeof(v) === 'function') { el[k] = v(el[k]); }
else { el[k] = v; }
return el[k];
};
var initialize = function (proxy) { var initialize = function (proxy) {
// run migration // run migration
if (typeof(proxy.data) !== 'object') { proxy.data = {}; } if (typeof(proxy.data) !== 'object') { proxy.data = {}; }
@ -56,6 +66,9 @@ define([
var api = {}; var api = {};
initialize(proxy); initialize(proxy);
api.val = function (id, k, v) {
return val(proxy, id, k, v);
};
api.add = function (id, obj) { api.add = function (id, obj) {
return add(proxy, id, obj); return add(proxy, id, obj);
}; };

Loading…
Cancel
Save