reactive-di
Advanced tools
Comparing version 5.0.6 to 6.0.0
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="6.0.0"></a> | ||
# [6.0.0](https://github.com/zerkalica/reactive-di/compare/v5.0.6...v6.0.0) (2017-11-25) | ||
<a name="5.0.6"></a> | ||
@@ -7,0 +12,0 @@ ## [5.0.6](https://github.com/zerkalica/reactive-di/compare/v5.0.5...v5.0.6) (2017-11-15) |
@@ -23,8 +23,6 @@ function _defineProperties(target, props) { | ||
var ATOM_FORCE_NONE = 0; | ||
var ATOM_FORCE_CACHE = 1; | ||
var rdiRendered = Symbol('rdiRendered'); | ||
var rdiInst = Symbol('rdiInst'); | ||
var rdiProp = Symbol('rdiProp'); | ||
var renderedKey = Symbol('lom_rendered'); | ||
var diKey = Symbol('rdi_di'); | ||
var DisposableSheet = | ||
@@ -116,3 +114,3 @@ /*#__PURE__*/ | ||
var sm = theme.sheetManager; | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
return sm === undefined ? fakeSheet : sm.sheet(di.displayName + (isInstance ? "[" + di.instance + "]" : ''), value || this[name + "#"](), !!this[name + "()"]); | ||
@@ -137,3 +135,3 @@ } | ||
var depId = 0; | ||
var rdiId = Symbol('rdi_id'); | ||
var rdiId = Symbol('rdiId'); | ||
@@ -214,3 +212,3 @@ var Alias = function Alias(dest) { | ||
value.displayName = this.displayName + "." + depName; | ||
value[diKey] = this; | ||
value[rdiInst] = this; | ||
var state = this._state === undefined ? undefined : this._state[depName]; | ||
@@ -237,3 +235,3 @@ | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
var isFn = false; | ||
var deps = key.deps; | ||
@@ -333,3 +331,3 @@ | ||
var listener = listeners[i]; | ||
listener[listener.constructor.__lom_prop] = props; | ||
listener[listener.constructor[rdiProp]] = props; | ||
} | ||
@@ -377,2 +375,3 @@ } | ||
if (argDeps === undefined) return result; | ||
var listeners = this._listeners; | ||
var resolved = this._resolved; | ||
@@ -391,8 +390,8 @@ | ||
if (resolved === false && key.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && key[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(dep); | ||
listeners.push(dep); | ||
} | ||
@@ -407,8 +406,8 @@ | ||
if (resolved === false && argDep.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && argDep[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(_dep); | ||
listeners.push(_dep); | ||
} | ||
@@ -538,3 +537,3 @@ | ||
_proto.r = function r(element, force) { | ||
_proto.r = function r(force) { | ||
var data; | ||
@@ -551,3 +550,3 @@ var render = this._render; | ||
}); | ||
error[renderedKey] = true; | ||
error[rdiRendered] = true; | ||
} | ||
@@ -568,3 +567,3 @@ | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
return this._el === undefined ? this.r(this._propsChanged) : this._el; | ||
}; | ||
@@ -699,20 +698,22 @@ | ||
var cloned = function cloned() { | ||
switch (arguments.length) { | ||
var a = arguments; | ||
switch (a.length) { | ||
case 1: | ||
return fn(arguments[0]); | ||
return fn(a[0]); | ||
case 2: | ||
return fn(arguments[0], arguments[1]); | ||
return fn(a[0], a[1]); | ||
case 3: | ||
return fn(arguments[0], arguments[1], arguments[2]); | ||
return fn(a[0], a[1], a[2]); | ||
case 4: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
return fn(a[0], a[1], a[2], a[3]); | ||
case 5: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
return fn(a[0], a[1], a[2], a[3], a[4]); | ||
default: | ||
return fn.apply(null, arguments); | ||
return fn.apply(null, a); | ||
} | ||
@@ -729,3 +730,3 @@ }; | ||
function props(proto, name, descr) { | ||
proto.constructor.__lom_prop = name; | ||
proto.constructor[rdiProp] = name; | ||
@@ -744,4 +745,3 @@ if (!descr.value && !descr.set) { | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
this._cache = undefined; | ||
@@ -767,12 +767,11 @@ this._host = host; | ||
this._cache = undefined; | ||
this.value(); | ||
this.value(false); | ||
}; | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
this._cache = this._host[this._propName](this._force); | ||
}; | ||
_proto.value = function value(next, force) { | ||
_proto.value = function value(force) { | ||
if (this._cache === undefined || force) { | ||
this._next = next; | ||
this._force = force; | ||
@@ -782,4 +781,3 @@ | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
} | ||
@@ -816,7 +814,7 @@ | ||
configurable: descr.configurable, | ||
value: function value(next, force) { | ||
value: function value(force) { | ||
var reaction = reactions.get(this); | ||
if (!reaction) { | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
reaction = new LomReaction(di ? di.displayName + "." + name : name, this, name + '$', reactions); | ||
@@ -826,3 +824,3 @@ reactions.set(this, reaction); | ||
return reaction.value(next, force); | ||
return reaction.value(force); | ||
} | ||
@@ -833,3 +831,3 @@ }; | ||
export { createReactWrapper, createCreateElement, Injector, cloneComponent, theme, props, createMobxDetached, renderedKey }; | ||
export { createReactWrapper, createCreateElement, Injector, cloneComponent, theme, props, createMobxDetached, rdiRendered }; | ||
//# sourceMappingURL=reactive-di.es.js.map |
@@ -27,8 +27,6 @@ 'use strict'; | ||
var ATOM_FORCE_NONE = 0; | ||
var ATOM_FORCE_CACHE = 1; | ||
var rdiRendered = Symbol('rdiRendered'); | ||
var rdiInst = Symbol('rdiInst'); | ||
var rdiProp = Symbol('rdiProp'); | ||
var renderedKey = Symbol('lom_rendered'); | ||
var diKey = Symbol('rdi_di'); | ||
var DisposableSheet = | ||
@@ -120,3 +118,3 @@ /*#__PURE__*/ | ||
var sm = theme.sheetManager; | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
return sm === undefined ? fakeSheet : sm.sheet(di.displayName + (isInstance ? "[" + di.instance + "]" : ''), value || this[name + "#"](), !!this[name + "()"]); | ||
@@ -141,3 +139,3 @@ } | ||
var depId = 0; | ||
var rdiId = Symbol('rdi_id'); | ||
var rdiId = Symbol('rdiId'); | ||
@@ -218,3 +216,3 @@ var Alias = function Alias(dest) { | ||
value.displayName = this.displayName + "." + depName; | ||
value[diKey] = this; | ||
value[rdiInst] = this; | ||
var state = this._state === undefined ? undefined : this._state[depName]; | ||
@@ -241,3 +239,3 @@ | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
var isFn = false; | ||
var deps = key.deps; | ||
@@ -337,3 +335,3 @@ | ||
var listener = listeners[i]; | ||
listener[listener.constructor.__lom_prop] = props; | ||
listener[listener.constructor[rdiProp]] = props; | ||
} | ||
@@ -381,2 +379,3 @@ } | ||
if (argDeps === undefined) return result; | ||
var listeners = this._listeners; | ||
var resolved = this._resolved; | ||
@@ -395,8 +394,8 @@ | ||
if (resolved === false && key.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && key[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(dep); | ||
listeners.push(dep); | ||
} | ||
@@ -411,8 +410,8 @@ | ||
if (resolved === false && argDep.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && argDep[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(_dep); | ||
listeners.push(_dep); | ||
} | ||
@@ -542,3 +541,3 @@ | ||
_proto.r = function r(element, force) { | ||
_proto.r = function r(force) { | ||
var data; | ||
@@ -555,3 +554,3 @@ var render = this._render; | ||
}); | ||
error[renderedKey] = true; | ||
error[rdiRendered] = true; | ||
} | ||
@@ -572,3 +571,3 @@ | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
return this._el === undefined ? this.r(this._propsChanged) : this._el; | ||
}; | ||
@@ -703,20 +702,22 @@ | ||
var cloned = function cloned() { | ||
switch (arguments.length) { | ||
var a = arguments; | ||
switch (a.length) { | ||
case 1: | ||
return fn(arguments[0]); | ||
return fn(a[0]); | ||
case 2: | ||
return fn(arguments[0], arguments[1]); | ||
return fn(a[0], a[1]); | ||
case 3: | ||
return fn(arguments[0], arguments[1], arguments[2]); | ||
return fn(a[0], a[1], a[2]); | ||
case 4: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
return fn(a[0], a[1], a[2], a[3]); | ||
case 5: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
return fn(a[0], a[1], a[2], a[3], a[4]); | ||
default: | ||
return fn.apply(null, arguments); | ||
return fn.apply(null, a); | ||
} | ||
@@ -733,3 +734,3 @@ }; | ||
function props(proto, name, descr) { | ||
proto.constructor.__lom_prop = name; | ||
proto.constructor[rdiProp] = name; | ||
@@ -748,4 +749,3 @@ if (!descr.value && !descr.set) { | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
this._cache = undefined; | ||
@@ -771,12 +771,11 @@ this._host = host; | ||
this._cache = undefined; | ||
this.value(); | ||
this.value(false); | ||
}; | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
this._cache = this._host[this._propName](this._force); | ||
}; | ||
_proto.value = function value(next, force) { | ||
_proto.value = function value(force) { | ||
if (this._cache === undefined || force) { | ||
this._next = next; | ||
this._force = force; | ||
@@ -786,4 +785,3 @@ | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
} | ||
@@ -820,7 +818,7 @@ | ||
configurable: descr.configurable, | ||
value: function value(next, force) { | ||
value: function value(force) { | ||
var reaction = reactions.get(this); | ||
if (!reaction) { | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
reaction = new LomReaction(di ? di.displayName + "." + name : name, this, name + '$', reactions); | ||
@@ -830,3 +828,3 @@ reactions.set(this, reaction); | ||
return reaction.value(next, force); | ||
return reaction.value(force); | ||
} | ||
@@ -844,3 +842,3 @@ }; | ||
exports.createMobxDetached = createMobxDetached; | ||
exports.renderedKey = renderedKey; | ||
exports.rdiRendered = rdiRendered; | ||
//# sourceMappingURL=reactive-di.js.map |
@@ -29,8 +29,6 @@ (function (global, factory) { | ||
var ATOM_FORCE_NONE = 0; | ||
var ATOM_FORCE_CACHE = 1; | ||
var rdiRendered = Symbol('rdiRendered'); | ||
var rdiInst = Symbol('rdiInst'); | ||
var rdiProp = Symbol('rdiProp'); | ||
var renderedKey = Symbol('lom_rendered'); | ||
var diKey = Symbol('rdi_di'); | ||
var DisposableSheet = | ||
@@ -122,3 +120,3 @@ /*#__PURE__*/ | ||
var sm = theme.sheetManager; | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
return sm === undefined ? fakeSheet : sm.sheet(di.displayName + (isInstance ? "[" + di.instance + "]" : ''), value || this[name + "#"](), !!this[name + "()"]); | ||
@@ -143,3 +141,3 @@ } | ||
var depId = 0; | ||
var rdiId = Symbol('rdi_id'); | ||
var rdiId = Symbol('rdiId'); | ||
@@ -220,3 +218,3 @@ var Alias = function Alias(dest) { | ||
value.displayName = this.displayName + "." + depName; | ||
value[diKey] = this; | ||
value[rdiInst] = this; | ||
var state = this._state === undefined ? undefined : this._state[depName]; | ||
@@ -243,3 +241,3 @@ | ||
_proto.invoke = function invoke(key) { | ||
var isFn = key.theme; | ||
var isFn = false; | ||
var deps = key.deps; | ||
@@ -339,3 +337,3 @@ | ||
var listener = listeners[i]; | ||
listener[listener.constructor.__lom_prop] = props; | ||
listener[listener.constructor[rdiProp]] = props; | ||
} | ||
@@ -383,2 +381,3 @@ } | ||
if (argDeps === undefined) return result; | ||
var listeners = this._listeners; | ||
var resolved = this._resolved; | ||
@@ -397,8 +396,8 @@ | ||
if (resolved === false && key.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && key[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(dep); | ||
listeners.push(dep); | ||
} | ||
@@ -413,8 +412,8 @@ | ||
if (resolved === false && argDep.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = []; | ||
if (resolved === false && argDep[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = []; | ||
} | ||
this._listeners.push(_dep); | ||
listeners.push(_dep); | ||
} | ||
@@ -544,3 +543,3 @@ | ||
_proto.r = function r(element, force) { | ||
_proto.r = function r(force) { | ||
var data; | ||
@@ -557,3 +556,3 @@ var render = this._render; | ||
}); | ||
error[renderedKey] = true; | ||
error[rdiRendered] = true; | ||
} | ||
@@ -574,3 +573,3 @@ | ||
_proto.render = function render() { | ||
return this._el === undefined ? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) : this._el; | ||
return this._el === undefined ? this.r(this._propsChanged) : this._el; | ||
}; | ||
@@ -705,20 +704,22 @@ | ||
var cloned = function cloned() { | ||
switch (arguments.length) { | ||
var a = arguments; | ||
switch (a.length) { | ||
case 1: | ||
return fn(arguments[0]); | ||
return fn(a[0]); | ||
case 2: | ||
return fn(arguments[0], arguments[1]); | ||
return fn(a[0], a[1]); | ||
case 3: | ||
return fn(arguments[0], arguments[1], arguments[2]); | ||
return fn(a[0], a[1], a[2]); | ||
case 4: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3]); | ||
return fn(a[0], a[1], a[2], a[3]); | ||
case 5: | ||
return fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); | ||
return fn(a[0], a[1], a[2], a[3], a[4]); | ||
default: | ||
return fn.apply(null, arguments); | ||
return fn.apply(null, a); | ||
} | ||
@@ -735,3 +736,3 @@ }; | ||
function props(proto, name, descr) { | ||
proto.constructor.__lom_prop = name; | ||
proto.constructor[rdiProp] = name; | ||
@@ -750,4 +751,3 @@ if (!descr.value && !descr.set) { | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
this._cache = undefined; | ||
@@ -773,12 +773,11 @@ this._host = host; | ||
this._cache = undefined; | ||
this.value(); | ||
this.value(false); | ||
}; | ||
_proto.__track = function __track() { | ||
this._cache = this._host[this._propName](this._next, this._force); | ||
this._cache = this._host[this._propName](this._force); | ||
}; | ||
_proto.value = function value(next, force) { | ||
_proto.value = function value(force) { | ||
if (this._cache === undefined || force) { | ||
this._next = next; | ||
this._force = force; | ||
@@ -788,4 +787,3 @@ | ||
this._next = undefined; | ||
this._force = undefined; | ||
this._force = false; | ||
} | ||
@@ -822,7 +820,7 @@ | ||
configurable: descr.configurable, | ||
value: function value(next, force) { | ||
value: function value(force) { | ||
var reaction = reactions.get(this); | ||
if (!reaction) { | ||
var di = this[diKey]; | ||
var di = this[rdiInst]; | ||
reaction = new LomReaction(di ? di.displayName + "." + name : name, this, name + '$', reactions); | ||
@@ -832,3 +830,3 @@ reactions.set(this, reaction); | ||
return reaction.value(next, force); | ||
return reaction.value(force); | ||
} | ||
@@ -846,3 +844,3 @@ }; | ||
exports.createMobxDetached = createMobxDetached; | ||
exports.renderedKey = renderedKey; | ||
exports.rdiRendered = rdiRendered; | ||
@@ -849,0 +847,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "reactive-di", | ||
"version": "5.0.6", | ||
"version": "6.0.0", | ||
"description": "Reactive dependency injection", | ||
@@ -65,3 +65,3 @@ "publishConfig": { | ||
"flow-bin": "^0.59.0", | ||
"lom_atom": "^2.0.10", | ||
"lom_atom": "^3.0.2", | ||
"mobx": "^3.3.1", | ||
@@ -68,0 +68,0 @@ "mocha": "^4.0.1", |
@@ -27,9 +27,10 @@ // @flow | ||
const cloned = function () { | ||
switch (arguments.length) { | ||
case 1: return fn(arguments[0]) | ||
case 2: return fn(arguments[0], arguments[1]) | ||
case 3: return fn(arguments[0], arguments[1], arguments[2]) | ||
case 4: return fn(arguments[0], arguments[1], arguments[2], arguments[3]) | ||
case 5: return fn(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]) | ||
default: return fn.apply(null, arguments) | ||
const a = arguments | ||
switch (a.length) { | ||
case 1: return fn(a[0]) | ||
case 2: return fn(a[0], a[1]) | ||
case 3: return fn(a[0], a[1], a[2]) | ||
case 4: return fn(a[0], a[1], a[2], a[3]) | ||
case 5: return fn(a[0], a[1], a[2], a[3], a[4]) | ||
default: return fn.apply(null, a) | ||
} | ||
@@ -36,0 +37,0 @@ } |
// @flow | ||
import type {DetachedDecoratorDescriptor, IAtomForce} from './interfaces' | ||
import {diKey} from './interfaces' | ||
import type {TypedPropertyDescriptor} from './interfaces' | ||
import {rdiInst} from './interfaces' | ||
import Injector from './Injector' | ||
@@ -15,3 +15,3 @@ | ||
_reaction: Reaction | ||
_handler: (next?: V | Error, force?: IAtomForce) => V | ||
_handler: (force: boolean) => V | ||
_cache: V | void | ||
@@ -21,4 +21,3 @@ _propName: string | ||
_reactions: WeakMap<Object, LomReaction<any>> | ||
_next: V | Error | void = undefined | ||
_force: IAtomForce | void = undefined | ||
_force: boolean = false | ||
_track: () => void | ||
@@ -43,16 +42,14 @@ | ||
this._cache = undefined | ||
this.value() | ||
this.value(false) | ||
} | ||
__track() { | ||
this._cache = this._host[this._propName](this._next, this._force) | ||
this._cache = this._host[this._propName](this._force) | ||
} | ||
value(next?: V | Error, force?: IAtomForce): V { | ||
value(force: boolean): V { | ||
if (this._cache === undefined || force) { | ||
this._next = next | ||
this._force = force | ||
this._reaction.track(this._track) | ||
this._next = undefined | ||
this._force = undefined | ||
this._force = false | ||
} | ||
@@ -76,3 +73,3 @@ | ||
name: string, | ||
descr: DetachedDecoratorDescriptor<V> | ||
descr: TypedPropertyDescriptor<(force: boolean) => V> | ||
) { | ||
@@ -92,6 +89,6 @@ const value = descr.value | ||
configurable: descr.configurable, | ||
value(next?: V | Error, force?: IAtomForce): V { | ||
value(force: boolean): V { | ||
let reaction: LomReaction<V> | void = reactions.get(this) | ||
if (!reaction) { | ||
const di: Injector | void = this[diKey] | ||
const di: Injector | void = this[rdiInst] | ||
reaction = new LomReaction( | ||
@@ -106,3 +103,3 @@ di ? `${di.displayName}.${name}` : name, | ||
return reaction.value(next, force) | ||
return reaction.value(force) | ||
} | ||
@@ -109,0 +106,0 @@ } |
// @flow | ||
import {ATOM_FORCE_NONE, ATOM_FORCE_CACHE} from './interfaces' | ||
import type {IAtomForce, DetachedDecorator} from './interfaces' | ||
import type {TypedPropertyDescriptor} from './interfaces' | ||
import Injector from './Injector' | ||
import type {IAtomize, IFromError, IRenderFn, IReactComponent, IProvideItem, IArg, IPropsWithContext} from './interfaces' | ||
import {renderedKey} from './interfaces' | ||
import {rdiRendered} from './interfaces' | ||
@@ -12,3 +11,3 @@ export default function createReactWrapper<IElement>( | ||
ErrorComponent: IFromError<IElement>, | ||
detached: DetachedDecorator<Object, any>, | ||
detached: TypedPropertyDescriptor<(force?: boolean) => any>, | ||
rootInjector?: Injector = new Injector(), | ||
@@ -93,3 +92,3 @@ isFullEqual?: boolean = false | ||
@detached r(element?: IElement, force?: IAtomForce): IElement { | ||
@detached r(force: boolean): IElement { | ||
let data: IElement | ||
@@ -105,3 +104,3 @@ | ||
data = this._injector.invokeWithProps(render.onError || ErrorComponent, {error}) | ||
error[renderedKey] = true | ||
error[rdiRendered] = true | ||
} | ||
@@ -122,3 +121,3 @@ Injector.parentContext = prevContext | ||
return this._el === undefined | ||
? this.r(undefined, this._propsChanged ? ATOM_FORCE_CACHE : ATOM_FORCE_NONE) | ||
? this.r(this._propsChanged) | ||
: this._el | ||
@@ -125,0 +124,0 @@ } |
@@ -10,3 +10,3 @@ // @flow | ||
export {default as createMobxDetached} from './createMobxDetached' | ||
export {renderedKey} from './interfaces' | ||
export {rdiRendered} from './interfaces' | ||
@@ -13,0 +13,0 @@ export type { |
// @flow | ||
import type {IArg, IProvideItem, IPropsWithContext, IDisposableSheet, IProcessor} from './interfaces' | ||
import {diKey} from './interfaces' | ||
import {rdiInst, rdiProp} from './interfaces' | ||
import SheetManager from './SheetManager' | ||
@@ -12,3 +12,3 @@ import theme from './theme' | ||
let depId = 0 | ||
const rdiId = Symbol('rdi_id') | ||
const rdiId = Symbol('rdiId') | ||
class Alias<T: Function> { | ||
@@ -95,3 +95,3 @@ dest: T | ||
value.displayName = `${this.displayName}.${depName}` | ||
value[diKey] = this | ||
value[rdiInst] = this | ||
const state = this._state === undefined ? undefined : this._state[depName] | ||
@@ -116,3 +116,3 @@ if (state && typeof state === 'object') { | ||
invoke<V>(key: any): V { | ||
let isFn = key.theme | ||
let isFn = false | ||
let deps: IArg[] | void = key.deps | ||
@@ -178,3 +178,3 @@ if (key._r !== undefined) { | ||
const listener = listeners[i] | ||
listener[listener.constructor.__lom_prop] = props | ||
listener[listener.constructor[rdiProp]] = props | ||
} | ||
@@ -210,3 +210,3 @@ } | ||
if (argDeps === undefined) return result | ||
let listeners = this._listeners | ||
const resolved = this._resolved | ||
@@ -220,7 +220,7 @@ for (let i = 0, l = argDeps.length; i < l; i++) { | ||
const dep = this.value(key) | ||
if (resolved === false && key.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = [] | ||
if (resolved === false && key[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = [] | ||
} | ||
this._listeners.push(dep) | ||
listeners.push(dep) | ||
} | ||
@@ -234,7 +234,7 @@ | ||
const dep = this.value(argDep) | ||
if (resolved === false && argDep.__lom_prop !== undefined) { | ||
if (this._listeners === undefined) { | ||
this._listeners = [] | ||
if (resolved === false && argDep[rdiProp] !== undefined) { | ||
if (listeners === undefined) { | ||
this._listeners = listeners = [] | ||
} | ||
this._listeners.push(dep) | ||
listeners.push(dep) | ||
} | ||
@@ -241,0 +241,0 @@ |
@@ -10,20 +10,9 @@ // @flow | ||
get?: () => T; | ||
set?: (value: T | Error) => void; | ||
set?: (value: T) => void; | ||
} | ||
export const ATOM_FORCE_NONE = 0 | ||
export const ATOM_FORCE_CACHE = 1 | ||
export const ATOM_FORCE_UPDATE = 2 | ||
export type IAtomForce = typeof ATOM_FORCE_CACHE | typeof ATOM_FORCE_UPDATE | typeof ATOM_FORCE_NONE | ||
export type IAtomPropHandler<V> = (next?: V | Error, force?: IAtomForce, oldValue?: V) => V | ||
export type DetachedDecoratorDescriptor<V> = TypedPropertyDescriptor<IAtomPropHandler<V>> | ||
export type DetachedDecorator<P: Object, V> = ( | ||
proto: P, | ||
name: string, | ||
descr: DetachedDecoratorDescriptor<V> | ||
) => DetachedDecoratorDescriptor<V> | ||
export const rdiRendered = Symbol('rdiRendered') | ||
export const rdiInst = Symbol('rdiInst') | ||
export const rdiProp = Symbol('rdiProp') | ||
export const renderedKey = Symbol('lom_rendered') | ||
export const diKey = Symbol('rdi_di') | ||
export type IArg = Function | {+[id: string]: Function} | ||
@@ -30,0 +19,0 @@ export type IProvideItem = Function | Object | [Function | string, Function | mixed] |
// @flow | ||
import type {TypedPropertyDescriptor} from './interfaces' | ||
import {rdiProp} from './interfaces' | ||
@@ -9,3 +10,3 @@ export default function props<P: Object>( | ||
) { | ||
proto.constructor.__lom_prop = name | ||
proto.constructor[rdiProp] = name | ||
if (!descr.value && !descr.set) { | ||
@@ -12,0 +13,0 @@ descr.writable = true |
// @flow | ||
import type {TypedPropertyDescriptor, ISheetManager, IDisposableSheet} from './interfaces' | ||
import {diKey} from './interfaces' | ||
import {rdiInst} from './interfaces' | ||
@@ -37,3 +37,3 @@ let lastThemeId = 0 | ||
const sm: ISheetManager | void = theme.sheetManager | ||
const di: Injector = this[diKey] | ||
const di: Injector = this[rdiInst] | ||
return sm === undefined | ||
@@ -40,0 +40,0 @@ ? fakeSheet |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
302851
2691