reactive-di
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -96,3 +96,4 @@ 'use strict'; | ||
var annotation /*: Annotation*/ = _extends({}, (raw /*: any*/), { | ||
key: (raw.key || dn) + '_' + this._createId(), | ||
level: raw.level || 0, | ||
strategy: raw.strategy || 'down', | ||
kind: raw.kind, | ||
@@ -99,0 +100,0 @@ displayName: raw.kind + '@' + dn, |
@@ -34,3 +34,4 @@ 'use strict'; | ||
Provider, | ||
AnnotationMap | ||
AnnotationMap, | ||
InjectorFindStrategy | ||
} from 'reactive-di'*/ | ||
@@ -58,11 +59,24 @@ | ||
var parents /*: Container[]*/ = this._parentChain = []; | ||
var chain /*: Container[]*/ = this._injectorsChain = [this]; | ||
var current /*: ?Container*/ = parent; | ||
while (current) { | ||
parents.push(current); | ||
chain.push(current); | ||
current = current._parent; | ||
} | ||
parents.push(this); | ||
this._revInjectorsChain = [].concat(chain).reverse(); | ||
} | ||
DiContainer.prototype._getInjectorStrategy = function _getInjectorStrategy(strategy /*: InjectorFindStrategy*/) { | ||
switch (strategy) { | ||
case 'down': | ||
return this._revInjectorsChain; | ||
case 'up': | ||
return this._injectorsChain; | ||
case 'self': | ||
return [this]; | ||
default: | ||
return this._revInjectorsChain; | ||
} | ||
}; | ||
DiContainer.prototype._getMiddlewares = function _getMiddlewares(target /*: DependencyKey*/, tags /*: Array<Tag>*/) { | ||
@@ -186,3 +200,3 @@ var middlewares = this._middlewares; | ||
DiContainer.prototype.getProvider = function getProvider(key /*: DependencyKey*/) { | ||
DiContainer.prototype.getProvider = function getProvider(key /*: DependencyKey*/, injectorsChain /*: Container[]*/) { | ||
var provider /*: ?Provider*/ = this._providerCache.get(key); | ||
@@ -195,7 +209,6 @@ if (provider) { | ||
} | ||
var container /*: Container*/ = this; | ||
var annotation /*: ?Annotation*/ = null; | ||
var chain /*: Container[]*/ = this._parentChain; | ||
for (var i = 0, l = chain.length; i < l; i++) { | ||
var annotation /*: ?Annotation*/ = void 0; | ||
var chain /*: Container[]*/ = injectorsChain || this._revInjectorsChain; | ||
for (var i = 0, l = chain.length; i < l && !annotation; i++) { | ||
container = chain[i]; | ||
@@ -202,0 +215,0 @@ annotation = container._annotations.get(key); |
@@ -23,5 +23,7 @@ /* @flow */ | ||
} | ||
declare type InjectorFindStrategy = 'up' | 'down' | 'self' | ||
declare interface RawAnnotation { | ||
kind: any; | ||
level?: number; | ||
strategy?: InjectorFindStrategy; | ||
tags?: Array<Tag>; | ||
@@ -38,2 +40,4 @@ deps?: Array<DepItem>; | ||
displayName: string; | ||
level: number; | ||
strategy: InjectorFindStrategy; | ||
tags: Array<Tag>; | ||
@@ -40,0 +44,0 @@ target: Dependency; |
{ | ||
"name": "reactive-di", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Reactive dependency injection", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
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
238403
2587