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

@ngrx/store

Package Overview
Dependencies
Maintainers
2
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngrx/store - npm Package Compare versions

Comparing version 1.5.0 to 2.0.0

reducer.d.ts

13

dispatcher.d.ts

@@ -1,4 +0,11 @@

import { Subject } from 'rxjs/Subject';
export declare class Dispatcher<T> extends Subject<T> {
dispatch(action: T): void;
import { SyncSubject } from '@ngrx/core/SyncSubject';
export interface Action {
type: string;
payload?: any;
}
export declare class Dispatcher extends SyncSubject<Action> {
static INIT: string;
constructor();
dispatch(action: Action): void;
complete(): void;
}

@@ -7,7 +7,7 @@ "use strict";

};
var Subject_1 = require('rxjs/Subject');
var SyncSubject_1 = require('@ngrx/core/SyncSubject');
var Dispatcher = (function (_super) {
__extends(Dispatcher, _super);
function Dispatcher() {
_super.apply(this, arguments);
_super.call(this, { type: Dispatcher.INIT });
}

@@ -17,4 +17,8 @@ Dispatcher.prototype.dispatch = function (action) {

};
Dispatcher.prototype.complete = function () {
// noop
};
Dispatcher.INIT = '@ngrx/store/init';
return Dispatcher;
}(Subject_1.Subject));
}(SyncSubject_1.SyncSubject));
exports.Dispatcher = Dispatcher;

@@ -1,6 +0,6 @@

export * from './interfaces';
export * from './dispatcher';
export * from './ng2';
export * from './reducer';
export * from './state';
export * from './store';
export * from './utils';
export * from './dispatcher';
export * from './store-backend';
export * from './ng2';

@@ -5,6 +5,7 @@ "use strict";

}
__export(require('./dispatcher'));
__export(require('./ng2'));
__export(require('./reducer'));
__export(require('./state'));
__export(require('./store'));
__export(require('./utils'));
__export(require('./dispatcher'));
__export(require('./store-backend'));
__export(require('./ng2'));
import { OpaqueToken, Provider } from '@angular/core';
import { Middleware } from './interfaces';
export declare const PRE_MIDDLEWARE: OpaqueToken;
export declare const POST_MIDDLEWARE: OpaqueToken;
export declare const RESOLVED_PRE_MIDDLEWARE: OpaqueToken;
export declare const RESOLVED_POST_MIDDLEWARE: OpaqueToken;
export declare const REDUCER: OpaqueToken;
export declare const INITIAL_REDUCER: OpaqueToken;
export declare const INITIAL_STATE: OpaqueToken;
export declare function provideStore(reducer: any, initialState?: any): Provider[];
export declare function usePreMiddleware(...middleware: Array<Middleware | Provider>): Provider[];
export declare function usePostMiddleware(...middleware: Array<Middleware | Provider>): Provider[];
export declare function createMiddleware(useFactory: (...deps: any[]) => Middleware, deps?: any[]): Provider;
export declare function provideMiddlewareForToken(token: any, _middleware: any[]): Provider[];
"use strict";
var core_1 = require('@angular/core');
var reducer_1 = require('./reducer');
var dispatcher_1 = require('./dispatcher');
var store_1 = require('./store');
var store_backend_1 = require('./store-backend');
var state_1 = require('./state');
var utils_1 = require('./utils');
exports.PRE_MIDDLEWARE = new core_1.OpaqueToken('ngrx/store/pre-middleware');
exports.POST_MIDDLEWARE = new core_1.OpaqueToken('ngrx/store/post-middleware');
exports.RESOLVED_PRE_MIDDLEWARE = new core_1.OpaqueToken('ngrx/store/resolved-pre-middleware');
exports.RESOLVED_POST_MIDDLEWARE = new core_1.OpaqueToken('ngrx/store/resolved-post-middleware');
exports.REDUCER = new core_1.OpaqueToken('ngrx/store/reducer');
exports.INITIAL_REDUCER = new core_1.OpaqueToken('ngrx/store/reducer');
exports.INITIAL_STATE = new core_1.OpaqueToken('ngrx/store/initial-state');

@@ -19,28 +16,22 @@ var dispatcherProvider = core_1.provide(dispatcher_1.Dispatcher, {

var storeProvider = core_1.provide(store_1.Store, {
deps: [dispatcher_1.Dispatcher, store_backend_1.StoreBackend, exports.INITIAL_STATE],
useFactory: function (dispatcher, backend, initialState) {
return new store_1.Store(dispatcher, backend, initialState);
deps: [dispatcher_1.Dispatcher, reducer_1.Reducer, state_1.State, exports.INITIAL_STATE],
useFactory: function (dispatcher, reducer, state$, initialState) {
return new store_1.Store(dispatcher, reducer, state$, initialState);
}
});
var storeBackendProvider = core_1.provide(store_backend_1.StoreBackend, {
deps: [dispatcher_1.Dispatcher, exports.REDUCER, exports.INITIAL_STATE, exports.RESOLVED_PRE_MIDDLEWARE, exports.RESOLVED_POST_MIDDLEWARE],
useFactory: function (dispatcher, reducer, initialState, preMiddleware, postMiddleware) {
return new store_backend_1.StoreBackend(dispatcher, reducer, initialState, preMiddleware, postMiddleware);
var stateProvider = core_1.provide(state_1.State, {
deps: [exports.INITIAL_STATE, dispatcher_1.Dispatcher, reducer_1.Reducer],
useFactory: function (initialState, dispatcher, reducer) {
return new state_1.State(initialState, dispatcher, reducer);
}
});
var resolvedPreMiddlewareProvider = core_1.provide(exports.RESOLVED_PRE_MIDDLEWARE, {
deps: [exports.PRE_MIDDLEWARE],
useFactory: function (middleware) {
return utils_1.compose.apply(void 0, middleware);
var reducerProvider = core_1.provide(reducer_1.Reducer, {
deps: [dispatcher_1.Dispatcher, exports.INITIAL_REDUCER],
useFactory: function (dispatcher, reducer) {
return new reducer_1.Reducer(dispatcher, reducer);
}
});
var resolvedPostMiddlewareProvider = core_1.provide(exports.RESOLVED_POST_MIDDLEWARE, {
deps: [exports.POST_MIDDLEWARE],
useFactory: function (middleware) {
return utils_1.compose.apply(void 0, middleware);
}
});
function provideStore(reducer, initialState) {
return [
core_1.provide(exports.REDUCER, {
core_1.provide(exports.INITIAL_REDUCER, {
useFactory: function () {

@@ -54,6 +45,6 @@ if (typeof reducer === 'function') {

core_1.provide(exports.INITIAL_STATE, {
deps: [exports.REDUCER],
deps: [exports.INITIAL_REDUCER],
useFactory: function (reducer) {
if (initialState === undefined) {
return reducer(undefined, { type: store_backend_1.ActionTypes.INIT });
return reducer(undefined, { type: dispatcher_1.Dispatcher.INIT });
}

@@ -63,54 +54,8 @@ return initialState;

}),
core_1.provide(exports.PRE_MIDDLEWARE, { multi: true, useValue: (function (T) { return T; }) }),
core_1.provide(exports.POST_MIDDLEWARE, { multi: true, useValue: (function (T) { return T; }) }),
dispatcherProvider,
storeProvider,
storeBackendProvider,
resolvedPreMiddlewareProvider,
resolvedPostMiddlewareProvider
stateProvider,
reducerProvider
];
}
exports.provideStore = provideStore;
function usePreMiddleware() {
var middleware = [];
for (var _i = 0; _i < arguments.length; _i++) {
middleware[_i - 0] = arguments[_i];
}
return provideMiddlewareForToken(exports.PRE_MIDDLEWARE, middleware);
}
exports.usePreMiddleware = usePreMiddleware;
function usePostMiddleware() {
var middleware = [];
for (var _i = 0; _i < arguments.length; _i++) {
middleware[_i - 0] = arguments[_i];
}
return provideMiddlewareForToken(exports.POST_MIDDLEWARE, middleware);
}
exports.usePostMiddleware = usePostMiddleware;
function createMiddleware(useFactory, deps) {
return core_1.provide(new core_1.OpaqueToken('@ngrx/store middleware'), {
deps: deps,
useFactory: useFactory
});
}
exports.createMiddleware = createMiddleware;
function provideMiddlewareForToken(token, _middleware) {
function isProvider(t) {
return t instanceof core_1.Provider;
}
var provider = core_1.provide(token, {
multi: true,
deps: [core_1.Injector],
useFactory: function (injector) {
var middleware = _middleware.map(function (m) {
if (isProvider(m)) {
return injector.get(m.token);
}
return m;
});
return utils_1.compose.apply(void 0, middleware);
}
});
return _middleware.filter(isProvider).concat([provider]);
}
exports.provideMiddlewareForToken = provideMiddlewareForToken;
{
"name": "@ngrx/store",
"version": "1.5.0",
"version": "2.0.0",
"description": "RxJS powered Redux for Angular2 apps",

@@ -33,2 +33,3 @@ "main": "./index.js",

"@angular/core": "^2.0.0-rc.0",
"@ngrx/core": "^1.0.0",
"es6-promise": "^3.0.2",

@@ -48,2 +49,3 @@ "es6-shim": "^0.35.0",

"peerDependencies": {
"@ngrx/core": "^1.0.0",
"rxjs": "5.0.0-beta.6",

@@ -50,0 +52,0 @@ "@angular/core": "^2.0.0-rc.0"

@@ -1,18 +0,16 @@

import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/distinctUntilChanged';
import { Action, Reducer } from './interfaces';
import { StoreBackend } from './store-backend';
import { Dispatcher } from './dispatcher';
export declare class Store<T> extends BehaviorSubject<T> {
import { SyncSubject } from '@ngrx/core/SyncSubject';
import { SelectSignature } from '@ngrx/core/operator/select';
import { Dispatcher, Action } from './dispatcher';
import { State } from './state';
import { Reducer, ActionReducer } from './reducer';
export declare class Store<T> extends SyncSubject<T> {
private _dispatcher;
private _backend;
constructor(_dispatcher: Dispatcher<Action>, _backend: StoreBackend, initialState?: T);
select<R>(keyOrSelector: ((state: T) => R) | string | number | symbol): Observable<R>;
getState(): T;
private _reducer;
constructor(_dispatcher: Dispatcher, _reducer: Reducer, state$: State<T>, initialState: T);
select: SelectSignature<T>;
replaceReducer(reducer: ActionReducer<any>): void;
dispatch(action: Action): void;
next(action: any): void;
error(error?: any): void;
replaceReducer<V>(reducer: Reducer<V>): void;
error(err: any): void;
complete(): void;
}

@@ -7,31 +7,17 @@ "use strict";

};
var BehaviorSubject_1 = require('rxjs/BehaviorSubject');
require('rxjs/add/operator/map');
require('rxjs/add/operator/distinctUntilChanged');
var SyncSubject_1 = require('@ngrx/core/SyncSubject');
var select_1 = require('@ngrx/core/operator/select');
var Store = (function (_super) {
__extends(Store, _super);
function Store(_dispatcher, _backend, initialState) {
function Store(_dispatcher, _reducer, state$, initialState) {
var _this = this;
_super.call(this, initialState);
this._dispatcher = _dispatcher;
this._backend = _backend;
_backend.connect(function (state) { return _super.prototype.next.call(_this, state); });
this._reducer = _reducer;
this.select = select_1.select.bind(this);
state$.subscribe(function (state) { return _super.prototype.next.call(_this, state); });
}
Store.prototype.select = function (keyOrSelector) {
if (typeof keyOrSelector === 'string' ||
typeof keyOrSelector === 'number' ||
typeof keyOrSelector === 'symbol') {
return this.map(function (state) { return state[keyOrSelector]; }).distinctUntilChanged();
}
else if (typeof keyOrSelector === 'function') {
return this.map(keyOrSelector).distinctUntilChanged();
}
else {
throw new TypeError("Store@select Unknown Parameter Type: "
+ ("Expected type of function or valid key type, got " + typeof keyOrSelector));
}
Store.prototype.replaceReducer = function (reducer) {
this._reducer.replaceReducer(reducer);
};
Store.prototype.getState = function () {
return this.value;
};
Store.prototype.dispatch = function (action) {

@@ -41,12 +27,12 @@ this._dispatcher.dispatch(action);

Store.prototype.next = function (action) {
this._dispatcher.next(action);
this._dispatcher.dispatch(action);
};
Store.prototype.error = function (error) {
this._dispatcher.error(error);
Store.prototype.error = function (err) {
this._dispatcher.error(err);
};
Store.prototype.replaceReducer = function (reducer) {
this._backend.replaceReducer(reducer);
Store.prototype.complete = function () {
// noop
};
return Store;
}(BehaviorSubject_1.BehaviorSubject));
}(SyncSubject_1.SyncSubject));
exports.Store = Store;

@@ -1,3 +0,2 @@

import { Reducer } from './interfaces';
export declare function combineReducers(reducers: any): Reducer<any>;
export declare const compose: (...funcs: any[]) => (...args: any[]) => any;
import { ActionReducer } from './reducer';
export declare function combineReducers(reducers: any): ActionReducer<any>;

@@ -28,19 +28,1 @@ "use strict";

exports.combineReducers = combineReducers;
exports.compose = function () {
var funcs = [];
for (var _i = 0; _i < arguments.length; _i++) {
funcs[_i - 0] = arguments[_i];
}
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
if (funcs.length === 0) {
return args[0];
}
var last = funcs[funcs.length - 1];
var rest = funcs.slice(0, -1);
return rest.reduceRight(function (composed, f) { return f(composed); }, last.apply(void 0, args));
};
};
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