reactive-di
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -21,3 +21,3 @@ 'use strict'; | ||
var BaseProvider = function () { | ||
function BaseProvider(annotation /*: Annotation*/) { | ||
function BaseProvider /*:: <InitState>*/(annotation /*: Annotation*/) { | ||
_classCallCheck(this, BaseProvider); | ||
@@ -32,3 +32,3 @@ | ||
BaseProvider.prototype.init = function init(container /*: Container*/) {}; // eslint-disable-line | ||
BaseProvider.prototype.init = function init(container /*: Container*/, initState /*: ?InitState*/) {}; // eslint-disable-line | ||
@@ -35,0 +35,0 @@ |
@@ -76,3 +76,3 @@ 'use strict'; | ||
DefaultContainerManager.prototype.createContainer = function createContainer(parent /*: Container*/) { | ||
DefaultContainerManager.prototype.createContainer = function createContainer(parent /*: Container*/, initState /*: Array<[DependencyKey, any]>*/) { | ||
var container /*: Container*/ = void 0; | ||
@@ -87,3 +87,3 @@ var self = this; | ||
container = new _DiContainer2.default(dispose, this._middlewares, this._updater, this._plugins, this._annotations, parent); | ||
container = new _DiContainer2.default(dispose, this._middlewares, this._updater, this._plugins, this._annotations, parent, new _SimpleMap2.default(initState || [])); | ||
this._containers.push(container); | ||
@@ -90,0 +90,0 @@ |
@@ -44,6 +44,7 @@ 'use strict'; | ||
var DefaultContainer = function () { | ||
function DefaultContainer(dispose /*: () => void*/, middlewares /*: Map<DependencyKey|Tag, Array<DependencyKey>>*/, updater /*: RelationUpdater*/, plugins /*: Map<string, Plugin>*/, annotations /*: AnnotationMap*/, parent /*: ?Container*/) { | ||
function DefaultContainer(dispose /*: () => void*/, middlewares /*: Map<DependencyKey|Tag, Array<DependencyKey>>*/, updater /*: RelationUpdater*/, plugins /*: Map<string, Plugin>*/, annotations /*: AnnotationMap*/, parent /*: ?Container*/, initState /*: Map<DependencyKey, any>*/) { | ||
_classCallCheck(this, DefaultContainer); | ||
this._dispose = dispose; | ||
this._initState = initState; | ||
this._middlewares = middlewares; | ||
@@ -168,6 +169,5 @@ this._updater = updater; | ||
} | ||
provider = plugin.create(annotation, (this /*: Container*/)); | ||
this._updater.begin(provider); | ||
provider.init((this /*: Container*/)); | ||
provider.init((this /*: Container*/), this._initState.get(annotatedDep)); | ||
this._updater.end(provider); | ||
@@ -174,0 +174,0 @@ |
@@ -27,3 +27,3 @@ 'use strict'; | ||
function ClassProvider /*:: <V: Object>*/(annotation /*: ClassAnnotation*/) { | ||
function ClassProvider /*:: <V>*/(annotation /*: ClassAnnotation*/) { | ||
_classCallCheck(this, ClassProvider); | ||
@@ -30,0 +30,0 @@ |
@@ -38,2 +38,8 @@ 'use strict'; | ||
ValueProvider.prototype.init = function init(container /*: Container*/, value /*: ?V*/) { | ||
if (value) { | ||
this.value = value; | ||
} | ||
}; | ||
ValueProvider.prototype.set = function set(value /*: V*/) { | ||
@@ -40,0 +46,0 @@ this.value = value; |
@@ -44,3 +44,3 @@ /* @flow */ | ||
export type PipeProvider<V> = { | ||
export type PipeProvider<V, InitState> = { | ||
type: 'pipe'; | ||
@@ -92,3 +92,3 @@ | ||
*/ | ||
init(container: Container): void; | ||
init(container: Container, initState: ?InitState): void; | ||
@@ -116,3 +116,3 @@ /** | ||
export type ValueProvider<V> = { | ||
export type ValueProvider<V, InitState> = { | ||
type: 'value'; | ||
@@ -127,3 +127,3 @@ set(v: V): boolean; | ||
value: V; | ||
init(container: Container): void; | ||
init(container: Container, initState: InitState): void; | ||
dispose(): void; | ||
@@ -135,3 +135,3 @@ update(): void; | ||
export type ListenerProvider<V> = { | ||
export type ListenerProvider<V, InitState> = { | ||
type: 'listener'; | ||
@@ -146,3 +146,3 @@ notify(): void; | ||
value: V; | ||
init(container: Container): void; | ||
init(container: Container, initState: InitState): void; | ||
dispose(): void; | ||
@@ -154,5 +154,6 @@ update(): void; | ||
export type EmiterProvider<V> = { | ||
export type EmiterProvider<V, InitState> = { | ||
type: 'emiter'; | ||
state: PromiseSource; | ||
reset(isNotify?: boolean): void; | ||
@@ -165,3 +166,3 @@ displayName: string; | ||
value: V; | ||
init(container: Container): void; | ||
init(container: Container, initState: InitState): void; | ||
dispose(): void; | ||
@@ -173,3 +174,3 @@ update(): void; | ||
export type Provider<V> = PipeProvider<V> | ValueProvider<V> | ListenerProvider<V> | EmiterProvider<V>; | ||
export type Provider = PipeProvider | ValueProvider | ListenerProvider | EmiterProvider; | ||
@@ -194,3 +195,3 @@ export type ArgumentHelper = { | ||
): ContainerManager; | ||
createContainer(parent?: Container): Container; | ||
createContainer(parent?: Container, state?: Array<[DependencyKey, any]>): Container; | ||
replace(oldDep: DependencyKey, newDep?: DependencyKey|Annotation): void; | ||
@@ -197,0 +198,0 @@ } |
@@ -52,6 +52,5 @@ /* @flow */ | ||
declare class BaseProvider<V> { | ||
declare class BaseProvider<InitState> { | ||
displayName: string; | ||
tags: Array<Tag>; | ||
value: V; | ||
isDisposed: boolean; | ||
@@ -61,3 +60,3 @@ isCached: boolean; | ||
init(container: Container): void; | ||
init(container: Container, initState: ?InitState): void; | ||
dispose(): void; | ||
@@ -64,0 +63,0 @@ update(): void; |
{ | ||
"name": "reactive-di", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"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
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
219107
2380