reactive-di
Advanced tools
Comparing version 3.1.7 to 3.1.8
@@ -112,2 +112,3 @@ 'use strict'; | ||
items[depInfo.id] = depInfo; | ||
key._rdiJsx = target._rdiJsx; | ||
@@ -114,0 +115,0 @@ if (key._rdiId) { |
@@ -105,3 +105,9 @@ 'use strict'; | ||
notifier.opId++; | ||
this._inHook = true;hook.willMount(target); | ||
this._inHook = true; | ||
try { | ||
hook.willMount(target); | ||
} catch (e) { | ||
this._inHook = false; | ||
throw e; | ||
} | ||
this._inHook = false; | ||
@@ -125,3 +131,9 @@ notifier.trace = oldTrace; | ||
notifier.opId++; | ||
this._inHook = true;hook.willUnmount(target); | ||
this._inHook = true; | ||
try { | ||
hook.willUnmount(target); | ||
} catch (e) { | ||
this._inHook = false; | ||
throw e; | ||
} | ||
this._inHook = false; | ||
@@ -143,3 +155,9 @@ notifier.trace = oldTrace; | ||
notifier.opId++; | ||
this._inHook = true;hook.willUpdate(target); | ||
this._inHook = true; | ||
try { | ||
hook.willUpdate(target); | ||
} catch (e) { | ||
this._inHook = false; | ||
throw e; | ||
} | ||
this._inHook = false; | ||
@@ -164,3 +182,9 @@ notifier.trace = oldTrace; | ||
notifier.opId++; | ||
this._inHook = true;hook.willUnmount(target); | ||
this._inHook = true; | ||
try { | ||
hook.willUnmount(target); | ||
} catch (e) { | ||
this._inHook = false; | ||
throw e; | ||
} | ||
this._inHook = false; | ||
@@ -181,3 +205,9 @@ notifier.trace = oldTrace; | ||
if (hook.selfUpdate) { | ||
notifier.trace = this.displayName + '.selfUpdate';hook.selfUpdate(target); | ||
notifier.trace = this.displayName + '.selfUpdate'; | ||
try { | ||
hook.selfUpdate(target); | ||
} catch (e) { | ||
this._inHook = false; | ||
throw e; | ||
} | ||
} | ||
@@ -184,0 +214,0 @@ notifier.trace = oldTrace; |
@@ -35,2 +35,3 @@ 'use strict'; | ||
if (this.logger) { | ||
this.trace = ''; | ||
this.logger.get().onError(e, name, isHandled); | ||
@@ -37,0 +38,0 @@ } |
@@ -42,4 +42,4 @@ 'use strict'; | ||
if (isEnder) { | ||
this._levels.push(this.level); | ||
this.level = this.stack.length; | ||
this._levels.push(this.level); | ||
} | ||
@@ -46,0 +46,0 @@ this.stack.push({ has: [], v: depItem, ender: isEnder || false }); |
@@ -18,3 +18,3 @@ 'use strict'; | ||
function copy(src, rec) { | ||
return typeof src.copy === 'function' ? src.copy(rec || {}) : Object.assign(Object.create(src.constructor.prototype), src, rec || {}); | ||
return Array.isArray(rec) ? rec : Object.assign(Object.create(src.constructor.prototype), src, rec || {}); | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -80,3 +80,2 @@ 'use strict'; | ||
var binder = this.context.binder; | ||
var level = binder.level; | ||
var stack = binder.stack; | ||
@@ -86,3 +85,2 @@ var source = this; | ||
var computeds = source.computeds; | ||
var i = stack.length; | ||
var status = binder.status; | ||
@@ -101,3 +99,3 @@ if (status) { | ||
while (--i >= 0) { | ||
for (var i = binder.level, l = stack.length; i < l; i++) { | ||
var rec = stack[i]; | ||
@@ -109,30 +107,26 @@ if (!rec.has[source.id]) { | ||
} | ||
if (i >= level) { | ||
rec.has[source.id] = true; | ||
/** | ||
* v is | ||
* | ||
* computed(1) - computed -> source.computeds (for cache invalidating), | ||
* source -> computed.sources (for caching, pass to another computed in future) | ||
* | ||
* consumer(2) - consumer -> source.consumers (for triggering state changes), | ||
* consumer -> source.computeds (for cache invalidating), | ||
* source.hook -> consumer.hooks (for livecycle callbacks) | ||
* | ||
* hook(4) - hook -> source.consumers (for triggering state changes), | ||
* hook -> source.computeds (for cache invalidating) | ||
*/ | ||
if (v.t === 0) { | ||
// computed | ||
computeds.push(v); | ||
v.sources.push(source); | ||
} else if (v.t === 2) { | ||
// consumer | ||
consumers.push(v); | ||
computeds.push(v); | ||
} else { | ||
// hook | ||
consumers.push(v); | ||
computeds.push(v); | ||
} | ||
rec.has[source.id] = true; | ||
/** | ||
* v is | ||
* | ||
* computed(1) - computed -> source.computeds (for cache invalidating), | ||
* source -> computed.sources (for caching, pass to another computed in future) | ||
* | ||
* consumer(2) - consumer -> source.consumers (for triggering state changes), | ||
* consumer -> source.computeds (for cache invalidating), | ||
* source.hook -> consumer.hooks (for livecycle callbacks) | ||
* | ||
* hook(4) - hook -> source.consumers (for triggering state changes), | ||
* hook -> source.computeds (for cache invalidating) | ||
*/ | ||
computeds.push(v); | ||
if (v.t === 0) { | ||
// computed | ||
v.sources.push(source); | ||
} else if (v.t === 2) { | ||
// consumer | ||
consumers.push(v); | ||
} else { | ||
// hook | ||
consumers.push(v); | ||
} | ||
@@ -182,3 +176,2 @@ } | ||
var status = new Source(null, this.context, this.id - 1, this.displayName + 'Status', new _SourceStatus2.default()); | ||
status.status = status; | ||
this.status = status; | ||
@@ -235,2 +228,5 @@ } | ||
} | ||
if (this.status) { | ||
this.status.reset(); | ||
} | ||
var computeds = this.computeds.items; | ||
@@ -237,0 +233,0 @@ for (var i = 0, l = computeds.length; i < l; i++) { |
@@ -18,4 +18,2 @@ 'use strict'; | ||
var completeObj = { complete: true, pending: false, error: null }; | ||
var RecoverableError = exports.RecoverableError = function (_Err) { | ||
@@ -57,3 +55,4 @@ _inherits(RecoverableError, _Err); | ||
this._v = null; | ||
this.displayName = source.displayName; | ||
this.displayName = this._notifier.trace; | ||
// + source.displayName | ||
this._id = ++this._notifier.opId; | ||
@@ -131,3 +130,2 @@ } | ||
notifier.opId = this._id; | ||
notifier.onError(error, this._source.displayName, true); | ||
this._status.merge({ error: error, complete: false, pending: false }); | ||
@@ -139,2 +137,3 @@ var observer = this._updater; | ||
this._promisable.reject(error); | ||
notifier.onError(error, this._source.displayName, true); | ||
notifier.opId = oldId; | ||
@@ -155,5 +154,3 @@ notifier.trace = oldTrace; | ||
var source = this._source; | ||
var status = this._status; | ||
status.merge(completeObj); | ||
var observer = this._updater; | ||
@@ -165,2 +162,4 @@ if (observer && observer.complete) { | ||
source.merge(v); | ||
} else { | ||
this._status.reset(); | ||
} | ||
@@ -167,0 +166,0 @@ this._promisable.resolve(v || this._v); |
{ | ||
"name": "reactive-di", | ||
"version": "3.1.7", | ||
"version": "3.1.8", | ||
"description": "Reactive dependency injection", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -133,2 +133,3 @@ // @flow | ||
items[depInfo.id] = depInfo | ||
key._rdiJsx = target._rdiJsx | ||
@@ -135,0 +136,0 @@ if (key._rdiId) { |
@@ -127,3 +127,8 @@ // @flow | ||
this._inHook = true | ||
;(hook: any).willMount(target) | ||
try { | ||
(hook: any).willMount(target) | ||
} catch (e) { | ||
this._inHook = false | ||
throw e | ||
} | ||
this._inHook = false | ||
@@ -148,3 +153,8 @@ notifier.trace = oldTrace | ||
this._inHook = true | ||
;(hook: any).willUnmount(target) | ||
try { | ||
(hook: any).willUnmount(target) | ||
} catch (e) { | ||
this._inHook = false | ||
throw e | ||
} | ||
this._inHook = false | ||
@@ -170,3 +180,8 @@ notifier.trace = oldTrace | ||
this._inHook = true | ||
;(hook: any).willUpdate(target) | ||
try { | ||
(hook: any).willUpdate(target) | ||
} catch (e) { | ||
this._inHook = false | ||
throw e | ||
} | ||
this._inHook = false | ||
@@ -192,3 +207,8 @@ notifier.trace = oldTrace | ||
this._inHook = true | ||
;(hook: any).willUnmount(target) | ||
try { | ||
(hook: any).willUnmount(target) | ||
} catch (e) { | ||
this._inHook = false | ||
throw e | ||
} | ||
this._inHook = false | ||
@@ -210,3 +230,8 @@ notifier.trace = oldTrace | ||
notifier.trace = this.displayName + '.selfUpdate' | ||
;(hook: any).selfUpdate(target) | ||
try { | ||
(hook: any).selfUpdate(target) | ||
} catch (e) { | ||
this._inHook = false | ||
throw e | ||
} | ||
} | ||
@@ -213,0 +238,0 @@ notifier.trace = oldTrace |
@@ -38,2 +38,3 @@ // @flow | ||
if (this.logger) { | ||
this.trace = '' | ||
this.logger.get().onError(e, name, isHandled) | ||
@@ -40,0 +41,0 @@ } |
@@ -35,4 +35,4 @@ // @flow | ||
if (isEnder) { | ||
this._levels.push(this.level) | ||
this.level = this.stack.length | ||
this._levels.push(this.level) | ||
} | ||
@@ -39,0 +39,0 @@ this.stack.push({has: [], v: depItem, ender: isEnder || false}) |
@@ -14,4 +14,4 @@ // @flow | ||
export function copy<V: Object>(src: V, rec?: {[id: $Keys<V>]: any}): V { | ||
return typeof src.copy === 'function' | ||
? src.copy(rec || {}) | ||
return Array.isArray(rec) | ||
? rec | ||
: Object.assign((Object.create(src.constructor.prototype): any), src, rec || {}) | ||
@@ -18,0 +18,0 @@ } |
@@ -84,3 +84,2 @@ // @flow | ||
const binder = this.context.binder | ||
const level = binder.level | ||
const stack = binder.stack | ||
@@ -90,3 +89,2 @@ let source: ISource<any> = (this: ISource<V>) | ||
let computeds = source.computeds | ||
let i = stack.length | ||
const status = binder.status | ||
@@ -105,3 +103,3 @@ if (status) { | ||
while (--i >= 0) { | ||
for (let i = binder.level, l = stack.length; i < l; i++) { | ||
const rec = stack[i] | ||
@@ -113,27 +111,23 @@ if (!rec.has[source.id]) { | ||
} | ||
if (i >= level) { | ||
rec.has[source.id] = true | ||
/** | ||
* v is | ||
* | ||
* computed(1) - computed -> source.computeds (for cache invalidating), | ||
* source -> computed.sources (for caching, pass to another computed in future) | ||
* | ||
* consumer(2) - consumer -> source.consumers (for triggering state changes), | ||
* consumer -> source.computeds (for cache invalidating), | ||
* source.hook -> consumer.hooks (for livecycle callbacks) | ||
* | ||
* hook(4) - hook -> source.consumers (for triggering state changes), | ||
* hook -> source.computeds (for cache invalidating) | ||
*/ | ||
if (v.t === 0) { // computed | ||
computeds.push((v: ICacheable<*> & IDisposable)) | ||
v.sources.push((source: ISource<*>)) | ||
} else if (v.t === 2) { // consumer | ||
consumers.push((v: INotifierItem)) | ||
computeds.push((v: ICacheable<*> & IDisposable)) | ||
} else { // hook | ||
consumers.push((v: INotifierItem)) | ||
computeds.push((v: ICacheable<*> & IDisposable)) | ||
} | ||
rec.has[source.id] = true | ||
/** | ||
* v is | ||
* | ||
* computed(1) - computed -> source.computeds (for cache invalidating), | ||
* source -> computed.sources (for caching, pass to another computed in future) | ||
* | ||
* consumer(2) - consumer -> source.consumers (for triggering state changes), | ||
* consumer -> source.computeds (for cache invalidating), | ||
* source.hook -> consumer.hooks (for livecycle callbacks) | ||
* | ||
* hook(4) - hook -> source.consumers (for triggering state changes), | ||
* hook -> source.computeds (for cache invalidating) | ||
*/ | ||
computeds.push((v: ICacheable<*> & IDisposable)) | ||
if (v.t === 0) { // computed | ||
v.sources.push((source: ISource<*>)) | ||
} else if (v.t === 2) { // consumer | ||
consumers.push((v: INotifierItem)) | ||
} else { // hook | ||
consumers.push((v: INotifierItem)) | ||
} | ||
@@ -193,3 +187,2 @@ } | ||
) | ||
status.status = status | ||
this.status = status | ||
@@ -251,2 +244,5 @@ } | ||
} | ||
if (this.status) { | ||
this.status.reset() | ||
} | ||
const computeds = this.computeds.items | ||
@@ -253,0 +249,0 @@ for (let i = 0, l = computeds.length; i < l; i++) { |
@@ -15,4 +15,2 @@ // @flow | ||
const completeObj = {complete: true, pending: false, error: null} | ||
export class RecoverableError extends Err { | ||
@@ -69,3 +67,4 @@ orig: Error | ||
this._v = (null: any) | ||
this.displayName = source.displayName | ||
this.displayName = this._notifier.trace | ||
// + source.displayName | ||
this._id = ++this._notifier.opId | ||
@@ -141,3 +140,2 @@ } | ||
notifier.opId = this._id | ||
notifier.onError(error, this._source.displayName, true) | ||
this._status.merge({error, complete: false, pending: false}) | ||
@@ -149,2 +147,3 @@ const observer = this._updater | ||
this._promisable.reject(error) | ||
notifier.onError(error, this._source.displayName, true) | ||
notifier.opId = oldId | ||
@@ -165,5 +164,3 @@ notifier.trace = oldTrace | ||
const source = this._source | ||
const status = this._status | ||
status.merge(completeObj) | ||
const observer = this._updater | ||
@@ -175,2 +172,4 @@ if (observer && observer.complete) { | ||
source.merge(v) | ||
} else { | ||
this._status.reset() | ||
} | ||
@@ -177,0 +176,0 @@ this._promisable.resolve(v || this._v) |
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
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
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
365649
5105