Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reactive-di

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactive-di - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

3

dist/core/ArgumentHelper.js

@@ -91,2 +91,3 @@ 'use strict';

dep.update();
dep.isCached = true;
}

@@ -100,2 +101,3 @@ argsObject[depNames[i]] = dep.value;

_dep.update();
_dep.isCached = true;
}

@@ -113,2 +115,3 @@ argsArray[_i] = _dep.value;

_dep2.update();
_dep2.isCached = true;
}

@@ -115,0 +118,0 @@ resolvedMiddlewares[_i2] = _dep2.value;

23

dist/core/BaseProvider.js

@@ -21,6 +21,5 @@ 'use strict';

var BaseProvider = function () {
function BaseProvider /*:: <V, Ann: Annotation, P: Provider>*/(annotation /*: Ann*/) {
function BaseProvider /*:: <V, A: Annotation, P: Provider>*/(annotation /*: A*/) {
_classCallCheck(this, BaseProvider);
this.annotation = annotation;
this.kind = annotation.kind;

@@ -35,20 +34,12 @@ this.dependencies = [((this /*: any*/) /*: P*/)];

BaseProvider.prototype.init = function init(container /*: Container*/) {}; // eslint-disable-line
BaseProvider.prototype.init = function init(annotation /*: A*/, container /*: Container*/) {}; // eslint-disable-line
BaseProvider.prototype.dispose = function dispose() {
this.isDisposed = true;
};
BaseProvider.prototype.update = function update() {
this.isCached = true;
};
BaseProvider.prototype.dispose = function dispose() {};
BaseProvider.prototype.addDependency = function addDependency(dependency /*: P*/) {
var deps = this.dependencies;
var l = deps.length;
deps[l] = dependency;
deps.length = l + 1;
dependency.addDependant(this);
};
BaseProvider.prototype.update = function update() {};
BaseProvider.prototype.addDependency = function addDependency(dependency /*: P*/) {}; // eslint-disable-line
BaseProvider.prototype.addDependant = function addDependant(dependant /*: P*/) {}; // eslint-disable-line

@@ -55,0 +46,0 @@

@@ -41,2 +41,3 @@ 'use strict';

provider.dispose();
provider.isDisposed = true; // eslint-disable-line
}

@@ -137,2 +138,3 @@

dep.update();
dep.isCached = true;
}

@@ -171,3 +173,3 @@

this._updater.begin(provider);
provider.init((this /*: Container*/));
provider.init(annotation, (this /*: Container*/));
this._updater.end(provider);

@@ -174,0 +176,0 @@

@@ -42,3 +42,5 @@ 'use strict';

var dependantSet = this._dependants[l];
var deps = dependant.dependencies;
function iterateMap(dependency /*: Provider*/) /*: void*/ {
deps.push(dependency);
dependant.addDependency(dependency);

@@ -45,0 +47,0 @@ }

@@ -28,9 +28,15 @@ 'use strict';

function ClassProvider /*:: <V: Object>*/() {
var _temp, _this, _ret;
_classCallCheck(this, ClassProvider);
return _possibleConstructorReturn(this, _BaseProvider.apply(this, arguments));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _BaseProvider.call.apply(_BaseProvider, [this].concat(args))), _this), _this._helper = (null /*: any*/), _temp), _possibleConstructorReturn(_this, _ret);
}
ClassProvider.prototype.init = function init(container /*: Container*/) {
this._helper = container.createArgumentHelper(this.annotation);
ClassProvider.prototype.init = function init(annotation /*: ClassAnnotation*/, container /*: Container*/) {
this._helper = container.createArgumentHelper(annotation);
};

@@ -40,5 +46,8 @@

this.value = this._helper.createObject();
this.isCached = true;
};
ClassProvider.prototype.addDependency = function addDependency(dependency /*: Provider*/) {
dependency.addDependant(this);
};
return ClassProvider;

@@ -45,0 +54,0 @@ }(_BaseProvider3.default);

@@ -34,4 +34,4 @@ 'use strict';

ComposeProvider.prototype.init = function init(container /*: Container*/) {
var helper /*: ArgumentHelper*/ = container.createArgumentHelper(this.annotation);
ComposeProvider.prototype.init = function init(annotation /*: ComposeAnnotation*/, container /*: Container*/) {
var helper /*: ArgumentHelper*/ = container.createArgumentHelper(annotation);
this.isCached = true;

@@ -47,6 +47,2 @@ this.value = function getValue() /*: V*/ {

ComposeProvider.prototype.addDependency = function addDependency(dependency /*: Provider*/) {
this.dependencies.push(dependency);
};
return ComposeProvider;

@@ -53,0 +49,0 @@ }(_BaseProvider3.default);

@@ -28,9 +28,15 @@ 'use strict';

function FactoryProvider /*:: <V>*/() {
var _temp, _this, _ret;
_classCallCheck(this, FactoryProvider);
return _possibleConstructorReturn(this, _BaseProvider.apply(this, arguments));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _BaseProvider.call.apply(_BaseProvider, [this].concat(args))), _this), _this._helper = (null /*: any*/), _temp), _possibleConstructorReturn(_this, _ret);
}
FactoryProvider.prototype.init = function init(container /*: Container*/) {
this._helper = container.createArgumentHelper(this.annotation);
FactoryProvider.prototype.init = function init(annotation /*: FactoryAnnotation*/, container /*: Container*/) {
this._helper = container.createArgumentHelper(annotation);
};

@@ -40,5 +46,8 @@

this.value = this._helper.invokeFunction();
this.isCached = true;
};
FactoryProvider.prototype.addDependency = function addDependency(dependency /*: Provider*/) {
dependency.addDependant(this);
};
return FactoryProvider;

@@ -45,0 +54,0 @@ }(_BaseProvider3.default);

@@ -9,6 +9,2 @@ 'use strict';

var _DisposableCollection = require('../../utils/DisposableCollection');
var _DisposableCollection2 = _interopRequireDefault(_DisposableCollection);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -27,3 +23,2 @@

/*:: import type {
Collection,
Provider

@@ -41,3 +36,2 @@ } from 'reactive-di/i/coreInterfaces'*/

_this.value = annotation.value;
_this._dependants = new _DisposableCollection2.default();
return _this;

@@ -48,17 +42,9 @@ }

this.value = value;
return true;
};
ValueProvider.prototype.reset = function reset() {
var deps = this._dependants.items;
for (var i = 0, l = deps.length; i < l; i++) {
deps[i].isCached = false;
}
ValueProvider.prototype.addDependency = function addDependency(dependency /*: Provider*/) {
dependency.addDependant(this);
};
ValueProvider.prototype.addDependant = function addDependant(dependant /*: Provider*/) {
this._dependants.add(dependant);
};
return ValueProvider;

@@ -65,0 +51,0 @@ }(_BaseProvider3.default);

@@ -32,10 +32,21 @@ /* @flow */

export type Provider<V, Ann: Annotation, P> = {
export type Provider<V, A: Annotation, P: Provider> = {
/**
* Provider type
*/
kind: any;
/**
* Debug name
*/
displayName: string;
/**
* Tags from annotation. Used in middlewares: cat attach middleware by tag.
*/
tags: Array<Tag>;
annotation: Ann;
/**
* Read only dependencies
* Cached dependencies. Used in Container.
* Not for use in Provider.
*/

@@ -45,6 +56,4 @@ dependencies: Array<P>;

/**
* Provider.get read this property if false - recalculates get result.
* Dependency provider can set isCached to false
*
* read/write
* If true - Container runs Provider.update()
* Provider.update() sets to true
*/

@@ -54,15 +63,43 @@ isCached: boolean;

/**
* Used for garbage collector, when disposing container
* Used in dependantas collections, sets to true when disposing container with dependantas.
* Ignore this dependants in for loops
*/
isDisposed: boolean;
/**
* Evaluated dependency value
*/
value: V;
init(container: Container): void;
/**
* Resolve dependencies here via Container.createArgumentHelper()
*
* @example
*
* ```js
* init(annotation: FactoryAnnotation, container: Container): void {
* this._helper = container.createArgumentHelper(annotation);
* }
* ```
*/
init(annotation: A, container: Container): void;
/**
* Set isDisposed = true and runs some logic for unsubscribes
*/
dispose(): void;
value: V;
/**
* Evaluate value and set isCached = true
*/
update(): void;
/**
* Add dependecy hook: noop by default
*/
addDependency(dependency: P): void;
/**
* Add dependant hook: noop by default
*/
addDependant(dependant: P): void;

@@ -69,0 +106,0 @@ }

@@ -51,16 +51,10 @@ /* @flow */

tags: Array<Tag>;
annotation: Ann;
value: V;
isDisposed: boolean;
isCached: boolean;
dependencies: Array<Provider|P>;
dependants: Collection<Provider|P>;
constructor(annotation: Ann): void;
init(container: Container): void;
init(annotation: Ann, container: Container): void;
dispose(): void;

@@ -67,0 +61,0 @@ update(): void;

{
"name": "reactive-di",
"version": "1.0.8",
"version": "1.0.9",
"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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc