UNPKG

wana

Version:

Easy observable state for React

59 lines (53 loc) 1.33 kB
'use strict'; var symbols = require('./c9633b27.js'); var is = require('@alloc/is'); let nextDebugId = 1; const $D = Symbol.for("wana:debug"); function getCurrentAuto() { return symbols.globals.auto; } function getDebug(target) { return target[$D]; } function setDebug(target, debug) { debug.name += "#" + nextDebugId++; target[$D] = debug; return target; } function addDebugAction(target, action) { const debug = getDebug(target); if (debug && debug.actions) { debug.actions.push(action); } } function noto(effect) { const {auto, observe} = symbols.globals; symbols.globals.auto = null; symbols.globals.observe = null; try { return effect(); } finally { symbols.globals.auto = auto; symbols.globals.observe = observe; } } function no(value) { if (is.is.function(value)) { if (value[symbols.$$]) return value; const fn = function(...args) { return noto(value.bind(this, ...args)); }; symbols.setHidden(fn, "name", value.name); symbols.setHidden(fn, symbols.$$, value); return fn; } return value && value[symbols.$$] || value; } exports.addDebugAction = addDebugAction; exports.getCurrentAuto = getCurrentAuto; exports.getDebug = getDebug; exports.no = no; exports.noto = noto; exports.setDebug = setDebug; //# sourceMappingURL=ffee02eb.js.map