reactive-di
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -13,3 +13,3 @@ 'use strict'; | ||
componentWillMount: function componentWillMount() { | ||
this._consumer = this.constructor.__factory.create(this); | ||
this._consumer = this.__factory.create(this); | ||
this._consumer.willMount(this.props); | ||
@@ -53,7 +53,9 @@ }, | ||
component.call(this, props, context); | ||
this.__factory = factory; | ||
} | ||
WrappedComponent.displayName = factory.displayName; | ||
WrappedComponent.__factory = factory; | ||
WrappedComponent.prototype = Object.create(this._ComponentProto); | ||
WrappedComponent.prototype.constructor = WrappedComponent; | ||
return WrappedComponent; | ||
@@ -60,0 +62,0 @@ }; |
@@ -21,3 +21,3 @@ 'use strict'; | ||
var Computed = function () { | ||
function Computed(meta, context) { | ||
function Computed(meta, context, isHook) { | ||
_classCallCheck(this, Computed); | ||
@@ -27,2 +27,3 @@ | ||
this.callId = 0; | ||
this.isHook = isHook; | ||
this.closed = false; | ||
@@ -114,2 +115,9 @@ this.cached = null; | ||
Computed.prototype.pull = function pull() { | ||
var value = this.cached || this.get(); | ||
if (value.didSelfUpdate) { | ||
value.didSelfUpdate(); | ||
} | ||
}; | ||
Computed.prototype.get = function get() { | ||
@@ -116,0 +124,0 @@ this.cached = this._cachedProxy; |
@@ -60,3 +60,3 @@ 'use strict'; | ||
DepFactory.prototype.computed = function computed(key, context, isHook) { | ||
DepFactory.prototype.computed = function computed(key, context) { | ||
var id = key._rdiId || ++this._lastId; // eslint-disable-line | ||
@@ -71,7 +71,22 @@ key._rdiId = id; // eslint-disable-line | ||
args: key._rdiArg || null, | ||
ender: key._rdiEnd || isHook || false, | ||
ender: key._rdiEnd || false, | ||
hook: key._rdiHook || null | ||
}, context); | ||
}, context, false); | ||
}; | ||
DepFactory.prototype.hook = function hook(key, context) { | ||
var id = key._rdiId || ++this._lastId; // eslint-disable-line | ||
key._rdiId = id; // eslint-disable-line | ||
return new _Computed2.default({ | ||
id: id, | ||
name: key._rdiKey || (0, _debugName2.default)(key), | ||
key: key, | ||
hook: null, | ||
func: key._rdiFn || false, | ||
args: key._rdiArg || null, | ||
ender: true | ||
}, context, true); | ||
}; | ||
DepFactory.prototype.source = function source(key, context) { | ||
@@ -78,0 +93,0 @@ var instance = !!key._rdiInst; |
@@ -111,4 +111,4 @@ 'use strict'; | ||
// consumer or computed | ||
if (rec.v.t === 2) { | ||
// consumer | ||
if (rec.v.t === 2 || rec.v.isHook) { | ||
// consumer, hook | ||
consumers.push(rec.v); | ||
@@ -115,0 +115,0 @@ } |
@@ -157,3 +157,3 @@ 'use strict'; | ||
} | ||
var rec = this._depFactory.computed(key, this, true); | ||
var rec = this._depFactory.hook(key, this); | ||
rec.resolve(); | ||
@@ -160,0 +160,0 @@ |
{ | ||
"name": "reactive-di", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "Reactive dependency injection", | ||
@@ -99,4 +99,5 @@ "publishConfig": { | ||
"derivable": "^0.12.1", | ||
"es6-error": "^4.0.1" | ||
"es6-error": "^4.0.1", | ||
"inferno": "^1.2.2" | ||
} | ||
} |
@@ -16,3 +16,3 @@ // @flow | ||
componentWillMount() { | ||
this._consumer = this.constructor.__factory.create((this: IHasForceUpdate<Object>)) | ||
this._consumer = this.__factory.create((this: IHasForceUpdate<Object>)) | ||
this._consumer.willMount(this.props) | ||
@@ -63,9 +63,11 @@ }, | ||
component.call(this, props, context) | ||
this.__factory = factory | ||
} | ||
WrappedComponent.displayName = factory.displayName | ||
WrappedComponent.__factory = factory | ||
WrappedComponent.prototype = Object.create(this._ComponentProto) | ||
WrappedComponent.prototype.constructor = WrappedComponent | ||
return (WrappedComponent: any) | ||
} | ||
} |
@@ -27,3 +27,3 @@ // @flow | ||
closed: boolean | ||
isHook: boolean | ||
callId: number | ||
@@ -49,6 +49,8 @@ cached: ?V | ||
meta: IComputedMeta, | ||
context: IContext | ||
context: IContext, | ||
isHook: boolean | ||
) { | ||
this.t = 0 | ||
this.callId = 0 | ||
this.isHook = isHook | ||
this.closed = false | ||
@@ -133,2 +135,9 @@ this.cached = null | ||
pull(): void { | ||
const value = this.cached || this.get() | ||
if (value.didSelfUpdate) { | ||
value.didSelfUpdate() | ||
} | ||
} | ||
_cachedProxy: V | ||
@@ -135,0 +144,0 @@ |
@@ -62,3 +62,3 @@ // @flow | ||
computed<V>(key: Function, context: IContext, isHook?: boolean): IComputed<V> { | ||
computed<V>(key: Function, context: IContext): IComputed<V> { | ||
const id = key._rdiId || ++this._lastId // eslint-disable-line | ||
@@ -74,9 +74,29 @@ key._rdiId = id // eslint-disable-line | ||
args: key._rdiArg || null, | ||
ender: key._rdiEnd || isHook || false, | ||
ender: key._rdiEnd || false, | ||
hook: key._rdiHook || null | ||
}, | ||
context | ||
context, | ||
false | ||
): any) | ||
} | ||
hook<V>(key: Function, context: IContext): IComputed<V> { | ||
const id = key._rdiId || ++this._lastId // eslint-disable-line | ||
key._rdiId = id // eslint-disable-line | ||
return (new Computed( | ||
{ | ||
id, | ||
name: key._rdiKey || debugName(key), | ||
key, | ||
hook: null, | ||
func: key._rdiFn || false, | ||
args: key._rdiArg || null, | ||
ender: true | ||
}, | ||
context, | ||
true | ||
): any) | ||
} | ||
source<V>(key: Function, context: IContext): ISource<V> { | ||
@@ -83,0 +103,0 @@ const instance = !!key._rdiInst |
@@ -46,2 +46,3 @@ // @flow | ||
willUpdate?: (next: V, prev: ?V) => void; | ||
didDepsUpdate?: () => void; | ||
} | ||
@@ -144,2 +145,5 @@ | ||
isHook: boolean; | ||
pull(): void; | ||
refs: number; | ||
@@ -311,2 +315,3 @@ context: IContext; | ||
computed<V>(key: Function, context: IContext): IComputed<V>; | ||
hook<V>(key: Function, context: IContext): IComputed<V>; | ||
source<V>(key: Function, context: IContext): ISource<V>; | ||
@@ -313,0 +318,0 @@ status(key: Function, context: IContext): IStatus; |
@@ -127,4 +127,4 @@ // @flow | ||
// consumer or computed | ||
if (rec.v.t === 2) { // consumer | ||
consumers.push(rec.v) | ||
if (rec.v.t === 2 || rec.v.isHook) { // consumer, hook | ||
consumers.push((rec.v: any)) | ||
} | ||
@@ -131,0 +131,0 @@ computeds.push(rec.v) |
@@ -194,3 +194,3 @@ // @flow | ||
} | ||
const rec: IComputed<V> = this._depFactory.computed(key, this, true) | ||
const rec: IComputed<V> = this._depFactory.hook(key, this) | ||
rec.resolve() | ||
@@ -197,0 +197,0 @@ |
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
363049
5039
3
94
+ Addedinferno@^1.2.2
+ Addedinferno@1.6.2(transitive)
+ Addedinferno-shared@1.6.1(transitive)
+ Addedinferno-vnode-flags@1.6.2(transitive)