New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ngrx/router-store

Package Overview
Dependencies
Maintainers
4
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngrx/router-store - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

63

@ngrx/router-store.es5.js

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

import { NgModule } from '@angular/core';
import { Inject, InjectionToken, NgModule } from '@angular/core';
import { NavigationCancel, NavigationError, Router, RoutesRecognized } from '@angular/router';

@@ -62,3 +62,17 @@ import { Store } from '@ngrx/store';

}
var _ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Internal Configuration');
var ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Configuration');
var DEFAULT_ROUTER_FEATURENAME = 'routerReducer';
/**
* @param {?} config
* @return {?}
*/
function _createDefaultRouterConfig(config) {
var /** @type {?} */ _config = {};
if (typeof config === 'function') {
_config = config();
}
return Object.assign({ stateKey: DEFAULT_ROUTER_FEATURENAME }, _config);
}
/**
* Connects RouterModule with StoreModule.

@@ -110,9 +124,12 @@ *

* @param {?} serializer
* @param {?} config
*/
function StoreRouterConnectingModule(store$$1, router$$1, serializer) {
function StoreRouterConnectingModule(store$$1, router$$1, serializer, config) {
this.store = store$$1;
this.router = router$$1;
this.serializer = serializer;
this.config = config;
this.dispatchTriggeredByRouter = false;
this.navigationTriggeredByDispatch = false;
this.stateKey = this.config.stateKey;
this.setUpBeforePreactivationHook();

@@ -123,4 +140,22 @@ this.setUpStoreStateListener();

/**
* @param {?=} config
* @return {?}
*/
StoreRouterConnectingModule.forRoot = function (config) {
if (config === void 0) { config = {}; }
return {
ngModule: StoreRouterConnectingModule,
providers: [
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],
};
};
/**
* @return {?}
*/
StoreRouterConnectingModule.prototype.setUpBeforePreactivationHook = function () {

@@ -143,3 +178,3 @@ var _this = this;

});
this.store.select('routerReducer').subscribe(function () {
this.store.select(this.stateKey).subscribe(function () {
_this.navigateIfNeeded();

@@ -152,3 +187,3 @@ });

StoreRouterConnectingModule.prototype.shouldDispatchRouterNavigation = function () {
if (!this.storeState['routerReducer'])
if (!this.storeState[this.stateKey])
return true;

@@ -161,4 +196,4 @@ return !this.navigationTriggeredByDispatch;

StoreRouterConnectingModule.prototype.navigateIfNeeded = function () {
if (!this.storeState['routerReducer'] ||
!this.storeState['routerReducer'].state) {
if (!this.storeState[this.stateKey] ||
!this.storeState[this.stateKey].state) {
return;

@@ -168,5 +203,5 @@ }

return;
if (this.router.url !== this.storeState['routerReducer'].state.url) {
if (this.router.url !== this.storeState[this.stateKey].state.url) {
this.navigationTriggeredByDispatch = true;
this.router.navigateByUrl(this.storeState['routerReducer'].state.url);
this.router.navigateByUrl(this.storeState[this.stateKey].state.url);
}

@@ -243,2 +278,11 @@ };

{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer },
{
provide: _ROUTER_CONFIG,
useValue: { stateKey: DEFAULT_ROUTER_FEATURENAME },
},
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],

@@ -254,2 +298,3 @@ },] },

{ type: RouterStateSerializer, },
{ type: undefined, decorators: [{ type: Inject, args: [ROUTER_CONFIG,] },] },
]; };

@@ -259,3 +304,3 @@ /**

*/
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, RouterStateSerializer, DefaultRouterStateSerializer };
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME, RouterStateSerializer, DefaultRouterStateSerializer, _ROUTER_CONFIG as ɵa, _createDefaultRouterConfig as ɵb };
//# sourceMappingURL=router-store.es5.js.map

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

import { NgModule } from '@angular/core';
import { Inject, InjectionToken, NgModule } from '@angular/core';
import { NavigationCancel, NavigationError, Router, RoutesRecognized } from '@angular/router';

@@ -58,3 +58,17 @@ import { Store } from '@ngrx/store';

}
const _ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Internal Configuration');
const ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Configuration');
const DEFAULT_ROUTER_FEATURENAME = 'routerReducer';
/**
* @param {?} config
* @return {?}
*/
function _createDefaultRouterConfig(config) {
let /** @type {?} */ _config = {};
if (typeof config === 'function') {
_config = config();
}
return Object.assign({ stateKey: DEFAULT_ROUTER_FEATURENAME }, _config);
}
/**
* Connects RouterModule with StoreModule.

@@ -106,9 +120,12 @@ *

* @param {?} serializer
* @param {?} config
*/
constructor(store$$1, router$$1, serializer) {
constructor(store$$1, router$$1, serializer, config) {
this.store = store$$1;
this.router = router$$1;
this.serializer = serializer;
this.config = config;
this.dispatchTriggeredByRouter = false;
this.navigationTriggeredByDispatch = false;
this.stateKey = this.config.stateKey;
this.setUpBeforePreactivationHook();

@@ -119,4 +136,21 @@ this.setUpStoreStateListener();

/**
* @param {?=} config
* @return {?}
*/
static forRoot(config = {}) {
return {
ngModule: StoreRouterConnectingModule,
providers: [
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],
};
}
/**
* @return {?}
*/
setUpBeforePreactivationHook() {

@@ -137,3 +171,3 @@ ((this.router)).hooks.beforePreactivation = (routerState) => {

});
this.store.select('routerReducer').subscribe(() => {
this.store.select(this.stateKey).subscribe(() => {
this.navigateIfNeeded();

@@ -146,3 +180,3 @@ });

shouldDispatchRouterNavigation() {
if (!this.storeState['routerReducer'])
if (!this.storeState[this.stateKey])
return true;

@@ -155,4 +189,4 @@ return !this.navigationTriggeredByDispatch;

navigateIfNeeded() {
if (!this.storeState['routerReducer'] ||
!this.storeState['routerReducer'].state) {
if (!this.storeState[this.stateKey] ||
!this.storeState[this.stateKey].state) {
return;

@@ -162,5 +196,5 @@ }

return;
if (this.router.url !== this.storeState['routerReducer'].state.url) {
if (this.router.url !== this.storeState[this.stateKey].state.url) {
this.navigationTriggeredByDispatch = true;
this.router.navigateByUrl(this.storeState['routerReducer'].state.url);
this.router.navigateByUrl(this.storeState[this.stateKey].state.url);
}

@@ -235,2 +269,11 @@ }

{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer },
{
provide: _ROUTER_CONFIG,
useValue: { stateKey: DEFAULT_ROUTER_FEATURENAME },
},
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],

@@ -246,2 +289,3 @@ },] },

{ type: RouterStateSerializer, },
{ type: undefined, decorators: [{ type: Inject, args: [ROUTER_CONFIG,] },] },
];

@@ -253,3 +297,3 @@

export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, RouterStateSerializer, DefaultRouterStateSerializer };
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME, RouterStateSerializer, DefaultRouterStateSerializer, _ROUTER_CONFIG as ɵa, _createDefaultRouterConfig as ɵb };
//# sourceMappingURL=router-store.js.map

@@ -64,3 +64,17 @@ (function (global, factory) {

}
var _ROUTER_CONFIG = new core.InjectionToken('@ngrx/router-store Internal Configuration');
var ROUTER_CONFIG = new core.InjectionToken('@ngrx/router-store Configuration');
var DEFAULT_ROUTER_FEATURENAME = 'routerReducer';
/**
* @param {?} config
* @return {?}
*/
function _createDefaultRouterConfig(config) {
var /** @type {?} */ _config = {};
if (typeof config === 'function') {
_config = config();
}
return Object.assign({ stateKey: DEFAULT_ROUTER_FEATURENAME }, _config);
}
/**
* Connects RouterModule with StoreModule.

@@ -112,9 +126,12 @@ *

* @param {?} serializer
* @param {?} config
*/
function StoreRouterConnectingModule(store$$1, router$$1, serializer) {
function StoreRouterConnectingModule(store$$1, router$$1, serializer, config) {
this.store = store$$1;
this.router = router$$1;
this.serializer = serializer;
this.config = config;
this.dispatchTriggeredByRouter = false;
this.navigationTriggeredByDispatch = false;
this.stateKey = this.config.stateKey;
this.setUpBeforePreactivationHook();

@@ -125,4 +142,22 @@ this.setUpStoreStateListener();

/**
* @param {?=} config
* @return {?}
*/
StoreRouterConnectingModule.forRoot = function (config) {
if (config === void 0) { config = {}; }
return {
ngModule: StoreRouterConnectingModule,
providers: [
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],
};
};
/**
* @return {?}
*/
StoreRouterConnectingModule.prototype.setUpBeforePreactivationHook = function () {

@@ -145,3 +180,3 @@ var _this = this;

});
this.store.select('routerReducer').subscribe(function () {
this.store.select(this.stateKey).subscribe(function () {
_this.navigateIfNeeded();

@@ -154,3 +189,3 @@ });

StoreRouterConnectingModule.prototype.shouldDispatchRouterNavigation = function () {
if (!this.storeState['routerReducer'])
if (!this.storeState[this.stateKey])
return true;

@@ -163,4 +198,4 @@ return !this.navigationTriggeredByDispatch;

StoreRouterConnectingModule.prototype.navigateIfNeeded = function () {
if (!this.storeState['routerReducer'] ||
!this.storeState['routerReducer'].state) {
if (!this.storeState[this.stateKey] ||
!this.storeState[this.stateKey].state) {
return;

@@ -170,5 +205,5 @@ }

return;
if (this.router.url !== this.storeState['routerReducer'].state.url) {
if (this.router.url !== this.storeState[this.stateKey].state.url) {
this.navigationTriggeredByDispatch = true;
this.router.navigateByUrl(this.storeState['routerReducer'].state.url);
this.router.navigateByUrl(this.storeState[this.stateKey].state.url);
}

@@ -245,2 +280,11 @@ };

{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer },
{
provide: _ROUTER_CONFIG,
useValue: { stateKey: DEFAULT_ROUTER_FEATURENAME },
},
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],

@@ -256,2 +300,3 @@ },] },

{ type: RouterStateSerializer, },
{ type: undefined, decorators: [{ type: core.Inject, args: [ROUTER_CONFIG,] },] },
]; };

@@ -264,4 +309,8 @@

exports.StoreRouterConnectingModule = StoreRouterConnectingModule;
exports.ROUTER_CONFIG = ROUTER_CONFIG;
exports.DEFAULT_ROUTER_FEATURENAME = DEFAULT_ROUTER_FEATURENAME;
exports.RouterStateSerializer = RouterStateSerializer;
exports.DefaultRouterStateSerializer = DefaultRouterStateSerializer;
exports.ɵa = _ROUTER_CONFIG;
exports.ɵb = _createDefaultRouterConfig;

@@ -268,0 +317,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

2

bundles/router-store.umd.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/router"),require("@ngrx/store"),require("rxjs/observable/of")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@ngrx/store","rxjs/observable/of"],e):e((t.ngrx=t.ngrx||{},t.ngrx.routerStore={}),t.ng.core,t.ng.router,t.ngrx.store,t.Rx.Observable)}(this,function(t,e,r,o,i){"use strict";function s(t,e){switch(e.type){case u:case h:case c:return{state:e.payload.routerState,navigationId:e.payload.event.id};default:return t}}var a=function(){function t(){}return t.prototype.serialize=function(t){},t}(),n=function(){function t(){}return t.prototype.serialize=function(t){return t},t}(),u="ROUTER_NAVIGATION",c="ROUTER_CANCEL",h="ROUTE_ERROR",p=function(){function t(t,e,r){this.store=t,this.router=e,this.serializer=r,this.dispatchTriggeredByRouter=!1,this.navigationTriggeredByDispatch=!1,this.setUpBeforePreactivationHook(),this.setUpStoreStateListener(),this.setUpStateRollbackEvents()}return t.prototype.setUpBeforePreactivationHook=function(){var t=this;this.router.hooks.beforePreactivation=function(e){return t.routerState=t.serializer.serialize(e),t.shouldDispatchRouterNavigation()&&t.dispatchRouterNavigation(),i.of(!0)}},t.prototype.setUpStoreStateListener=function(){var t=this;this.store.subscribe(function(e){t.storeState=e}),this.store.select("routerReducer").subscribe(function(){t.navigateIfNeeded()})},t.prototype.shouldDispatchRouterNavigation=function(){return!this.storeState.routerReducer||!this.navigationTriggeredByDispatch},t.prototype.navigateIfNeeded=function(){this.storeState.routerReducer&&this.storeState.routerReducer.state&&(this.dispatchTriggeredByRouter||this.router.url!==this.storeState.routerReducer.state.url&&(this.navigationTriggeredByDispatch=!0,this.router.navigateByUrl(this.storeState.routerReducer.state.url)))},t.prototype.setUpStateRollbackEvents=function(){var t=this;this.router.events.subscribe(function(e){e instanceof r.RoutesRecognized?t.lastRoutesRecognized=e:e instanceof r.NavigationCancel?t.dispatchRouterCancel(e):e instanceof r.NavigationError&&t.dispatchRouterError(e)})},t.prototype.dispatchRouterNavigation=function(){this.dispatchRouterAction(u,{routerState:this.routerState,event:new r.RoutesRecognized(this.lastRoutesRecognized.id,this.lastRoutesRecognized.url,this.lastRoutesRecognized.urlAfterRedirects,this.routerState)})},t.prototype.dispatchRouterCancel=function(t){this.dispatchRouterAction(c,{routerState:this.routerState,storeState:this.storeState,event:t})},t.prototype.dispatchRouterError=function(t){this.dispatchRouterAction(h,{routerState:this.routerState,storeState:this.storeState,event:new r.NavigationError(t.id,t.url,""+t)})},t.prototype.dispatchRouterAction=function(t,e){this.dispatchTriggeredByRouter=!0;try{this.store.dispatch({type:t,payload:e})}finally{this.dispatchTriggeredByRouter=!1,this.navigationTriggeredByDispatch=!1}},t}();p.decorators=[{type:e.NgModule,args:[{providers:[{provide:a,useClass:n}]}]}],p.ctorParameters=function(){return[{type:o.Store},{type:r.Router},{type:a}]},t.ROUTER_ERROR=h,t.ROUTER_CANCEL=c,t.ROUTER_NAVIGATION=u,t.routerReducer=s,t.StoreRouterConnectingModule=p,t.RouterStateSerializer=a,t.DefaultRouterStateSerializer=n,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/router"),require("@ngrx/store"),require("rxjs/observable/of")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@ngrx/store","rxjs/observable/of"],e):e((t.ngrx=t.ngrx||{},t.ngrx.routerStore={}),t.ng.core,t.ng.router,t.ngrx.store,t.Rx.Observable)}(this,function(t,e,r,o,i){"use strict";function s(t,e){switch(e.type){case c:case h:case p:return{state:e.payload.routerState,navigationId:e.payload.event.id};default:return t}}function n(t){var e={};return"function"==typeof t&&(e=t()),Object.assign({stateKey:R},e)}var a=function(){function t(){}return t.prototype.serialize=function(t){},t}(),u=function(){function t(){}return t.prototype.serialize=function(t){return t},t}(),c="ROUTER_NAVIGATION",p="ROUTER_CANCEL",h="ROUTE_ERROR",d=new e.InjectionToken("@ngrx/router-store Internal Configuration"),g=new e.InjectionToken("@ngrx/router-store Configuration"),R="routerReducer",f=function(){function t(t,e,r,o){this.store=t,this.router=e,this.serializer=r,this.config=o,this.dispatchTriggeredByRouter=!1,this.navigationTriggeredByDispatch=!1,this.stateKey=this.config.stateKey,this.setUpBeforePreactivationHook(),this.setUpStoreStateListener(),this.setUpStateRollbackEvents()}return t.forRoot=function(e){return void 0===e&&(e={}),{ngModule:t,providers:[{provide:d,useValue:e},{provide:g,useFactory:n,deps:[d]}]}},t.prototype.setUpBeforePreactivationHook=function(){var t=this;this.router.hooks.beforePreactivation=function(e){return t.routerState=t.serializer.serialize(e),t.shouldDispatchRouterNavigation()&&t.dispatchRouterNavigation(),i.of(!0)}},t.prototype.setUpStoreStateListener=function(){var t=this;this.store.subscribe(function(e){t.storeState=e}),this.store.select(this.stateKey).subscribe(function(){t.navigateIfNeeded()})},t.prototype.shouldDispatchRouterNavigation=function(){return!this.storeState[this.stateKey]||!this.navigationTriggeredByDispatch},t.prototype.navigateIfNeeded=function(){this.storeState[this.stateKey]&&this.storeState[this.stateKey].state&&(this.dispatchTriggeredByRouter||this.router.url!==this.storeState[this.stateKey].state.url&&(this.navigationTriggeredByDispatch=!0,this.router.navigateByUrl(this.storeState[this.stateKey].state.url)))},t.prototype.setUpStateRollbackEvents=function(){var t=this;this.router.events.subscribe(function(e){e instanceof r.RoutesRecognized?t.lastRoutesRecognized=e:e instanceof r.NavigationCancel?t.dispatchRouterCancel(e):e instanceof r.NavigationError&&t.dispatchRouterError(e)})},t.prototype.dispatchRouterNavigation=function(){this.dispatchRouterAction(c,{routerState:this.routerState,event:new r.RoutesRecognized(this.lastRoutesRecognized.id,this.lastRoutesRecognized.url,this.lastRoutesRecognized.urlAfterRedirects,this.routerState)})},t.prototype.dispatchRouterCancel=function(t){this.dispatchRouterAction(p,{routerState:this.routerState,storeState:this.storeState,event:t})},t.prototype.dispatchRouterError=function(t){this.dispatchRouterAction(h,{routerState:this.routerState,storeState:this.storeState,event:new r.NavigationError(t.id,t.url,""+t)})},t.prototype.dispatchRouterAction=function(t,e){this.dispatchTriggeredByRouter=!0;try{this.store.dispatch({type:t,payload:e})}finally{this.dispatchTriggeredByRouter=!1,this.navigationTriggeredByDispatch=!1}},t}();f.decorators=[{type:e.NgModule,args:[{providers:[{provide:a,useClass:u},{provide:d,useValue:{stateKey:R}},{provide:g,useFactory:n,deps:[d]}]}]}],f.ctorParameters=function(){return[{type:o.Store},{type:r.Router},{type:a},{type:void 0,decorators:[{type:e.Inject,args:[g]}]}]},t.ROUTER_ERROR=h,t.ROUTER_CANCEL=p,t.ROUTER_NAVIGATION=c,t.routerReducer=s,t.StoreRouterConnectingModule=f,t.ROUTER_CONFIG=g,t.DEFAULT_ROUTER_FEATURENAME=R,t.RouterStateSerializer=a,t.DefaultRouterStateSerializer=u,t.ɵa=d,t.ɵb=n,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=./dist/router-store/bundles/router-store.umd.min.js.map
{
"name": "@ngrx/router-store",
"version": "4.1.0",
"version": "4.1.1",
"description": "Bindings to connect @angular/router to @ngrx/store",

@@ -23,5 +23,5 @@ "module": "@ngrx/router-store.es5.js",

"peerDependencies": {
"@angular/common": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/router": "^4.0.0",
"@angular/common": "^4.0.0 || ^5.0.0-rc.2 || ^5.0.0",
"@angular/core": "^4.0.0 || ^5.0.0-rc.2 || ^5.0.0",
"@angular/router": "^4.0.0 || ^5.0.0-rc.2 || ^5.0.0",
"@ngrx/store": "^4.0.0",

@@ -28,0 +28,0 @@ "rxjs": "^5.0.0"

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

export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, RouterStateSerializer, DefaultRouterStateSerializer } from './src/index';
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME, RouterStateSerializer, DefaultRouterStateSerializer } from './src/index';
//# sourceMappingURL=public_api.js.map

@@ -5,1 +5,2 @@ /**

export * from './public_api';
export { _ROUTER_CONFIG as ɵa, _createDefaultRouterConfig as ɵb } from './src/router_store_module';
/**
* Generated bundle index. Do not edit.
*/
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, RouterStateSerializer, DefaultRouterStateSerializer } from './public_api';
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME, RouterStateSerializer, DefaultRouterStateSerializer } from './public_api';
export { _ROUTER_CONFIG as ɵa, _createDefaultRouterConfig as ɵb } from './src/router_store_module';
//# sourceMappingURL=index.js.map

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

{"__symbolic":"module","version":3,"metadata":{"ROUTER_ERROR":"ROUTE_ERROR","ROUTER_CANCEL":"ROUTER_CANCEL","ROUTER_NAVIGATION":"ROUTER_NAVIGATION","RouterNavigationAction":{"__symbolic":"interface"},"RouterCancelAction":{"__symbolic":"interface"},"RouterErrorAction":{"__symbolic":"interface"},"RouterAction":{"__symbolic":"interface"},"routerReducer":{"__symbolic":"function"},"RouterErrorPayload":{"__symbolic":"interface"},"RouterReducerState":{"__symbolic":"interface"},"RouterCancelPayload":{"__symbolic":"interface"},"RouterNavigationPayload":{"__symbolic":"interface"},"StoreRouterConnectingModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","name":"RouterStateSerializer"},"useClass":{"__symbolic":"reference","name":"DefaultRouterStateSerializer"}}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Store","module":"@ngrx/store","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","module":"@angular/router","name":"Router"},{"__symbolic":"reference","name":"RouterStateSerializer"}]}],"setUpBeforePreactivationHook":[{"__symbolic":"method"}],"setUpStoreStateListener":[{"__symbolic":"method"}],"shouldDispatchRouterNavigation":[{"__symbolic":"method"}],"navigateIfNeeded":[{"__symbolic":"method"}],"setUpStateRollbackEvents":[{"__symbolic":"method"}],"dispatchRouterNavigation":[{"__symbolic":"method"}],"dispatchRouterCancel":[{"__symbolic":"method"}],"dispatchRouterError":[{"__symbolic":"method"}],"dispatchRouterAction":[{"__symbolic":"method"}]}},"RouterStateSerializer":{"__symbolic":"class","arity":1,"members":{"serialize":[{"__symbolic":"method"}]}},"DefaultRouterStateSerializer":{"__symbolic":"class","members":{"serialize":[{"__symbolic":"method"}]}}},"origins":{"ROUTER_ERROR":"./src/router_store_module","ROUTER_CANCEL":"./src/router_store_module","ROUTER_NAVIGATION":"./src/router_store_module","RouterNavigationAction":"./src/router_store_module","RouterCancelAction":"./src/router_store_module","RouterErrorAction":"./src/router_store_module","RouterAction":"./src/router_store_module","routerReducer":"./src/router_store_module","RouterErrorPayload":"./src/router_store_module","RouterReducerState":"./src/router_store_module","RouterCancelPayload":"./src/router_store_module","RouterNavigationPayload":"./src/router_store_module","StoreRouterConnectingModule":"./src/router_store_module","RouterStateSerializer":"./src/serializer","DefaultRouterStateSerializer":"./src/serializer"},"importAs":"@ngrx/router-store"}
{"__symbolic":"module","version":3,"metadata":{"ɵa":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["@ngrx/router-store Internal Configuration"]},"ɵb":{"__symbolic":"function"},"ROUTER_ERROR":"ROUTE_ERROR","ROUTER_CANCEL":"ROUTER_CANCEL","ROUTER_NAVIGATION":"ROUTER_NAVIGATION","RouterNavigationAction":{"__symbolic":"interface"},"RouterCancelAction":{"__symbolic":"interface"},"RouterErrorAction":{"__symbolic":"interface"},"RouterAction":{"__symbolic":"interface"},"routerReducer":{"__symbolic":"function"},"RouterErrorPayload":{"__symbolic":"interface"},"RouterReducerState":{"__symbolic":"interface"},"RouterCancelPayload":{"__symbolic":"interface"},"RouterNavigationPayload":{"__symbolic":"interface"},"StoreRouterConnectingModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"providers":[{"provide":{"__symbolic":"reference","name":"RouterStateSerializer"},"useClass":{"__symbolic":"reference","name":"DefaultRouterStateSerializer"}},{"provide":{"__symbolic":"reference","name":"ɵa"},"useValue":{"stateKey":{"__symbolic":"reference","name":"DEFAULT_ROUTER_FEATURENAME"}}},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIG"},"useFactory":{"__symbolic":"reference","name":"ɵb"},"deps":[{"__symbolic":"reference","name":"ɵa"}]}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"ROUTER_CONFIG"}]}]],"parameters":[{"__symbolic":"reference","name":"Store","module":"@ngrx/store","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","module":"@angular/router","name":"Router"},{"__symbolic":"reference","name":"RouterStateSerializer"},{"__symbolic":"error","message":"Could not resolve type","line":230,"character":43,"context":{"typeName":"StoreRouterConfig"},"module":"./src/router_store_module"}]}],"setUpBeforePreactivationHook":[{"__symbolic":"method"}],"setUpStoreStateListener":[{"__symbolic":"method"}],"shouldDispatchRouterNavigation":[{"__symbolic":"method"}],"navigateIfNeeded":[{"__symbolic":"method"}],"setUpStateRollbackEvents":[{"__symbolic":"method"}],"dispatchRouterNavigation":[{"__symbolic":"method"}],"dispatchRouterCancel":[{"__symbolic":"method"}],"dispatchRouterError":[{"__symbolic":"method"}],"dispatchRouterAction":[{"__symbolic":"method"}]},"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"defaults":[{}],"value":{"ngModule":{"__symbolic":"reference","name":"StoreRouterConnectingModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵa"},"useValue":{"__symbolic":"reference","name":"config"}},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIG"},"useFactory":{"__symbolic":"reference","name":"ɵb"},"deps":[{"__symbolic":"reference","name":"ɵa"}]}]}}}},"StoreRouterConfig":{"__symbolic":"interface"},"StoreRouterConfigFunction":{"__symbolic":"interface"},"ROUTER_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["@ngrx/router-store Configuration"]},"DEFAULT_ROUTER_FEATURENAME":"routerReducer","RouterStateSerializer":{"__symbolic":"class","arity":1,"members":{"serialize":[{"__symbolic":"method"}]}},"DefaultRouterStateSerializer":{"__symbolic":"class","members":{"serialize":[{"__symbolic":"method"}]}}},"origins":{"ɵa":"./src/router_store_module","ɵb":"./src/router_store_module","ROUTER_ERROR":"./src/router_store_module","ROUTER_CANCEL":"./src/router_store_module","ROUTER_NAVIGATION":"./src/router_store_module","RouterNavigationAction":"./src/router_store_module","RouterCancelAction":"./src/router_store_module","RouterErrorAction":"./src/router_store_module","RouterAction":"./src/router_store_module","routerReducer":"./src/router_store_module","RouterErrorPayload":"./src/router_store_module","RouterReducerState":"./src/router_store_module","RouterCancelPayload":"./src/router_store_module","RouterNavigationPayload":"./src/router_store_module","StoreRouterConnectingModule":"./src/router_store_module","StoreRouterConfig":"./src/router_store_module","StoreRouterConfigFunction":"./src/router_store_module","ROUTER_CONFIG":"./src/router_store_module","DEFAULT_ROUTER_FEATURENAME":"./src/router_store_module","RouterStateSerializer":"./src/serializer","DefaultRouterStateSerializer":"./src/serializer"},"importAs":"@ngrx/router-store"}

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

export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, RouterNavigationAction, RouterCancelAction, RouterErrorAction, RouterAction, routerReducer, RouterErrorPayload, RouterReducerState, RouterCancelPayload, RouterNavigationPayload, StoreRouterConnectingModule } from './router_store_module';
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, RouterNavigationAction, RouterCancelAction, RouterErrorAction, RouterAction, routerReducer, RouterErrorPayload, RouterReducerState, RouterCancelPayload, RouterNavigationPayload, StoreRouterConnectingModule, StoreRouterConfig, StoreRouterConfigFunction, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME } from './router_store_module';
export { RouterStateSerializer, DefaultRouterStateSerializer } from './serializer';

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

export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, } from './router_store_module';
export { ROUTER_ERROR, ROUTER_CANCEL, ROUTER_NAVIGATION, routerReducer, StoreRouterConnectingModule, ROUTER_CONFIG, DEFAULT_ROUTER_FEATURENAME, } from './router_store_module';
export { RouterStateSerializer, DefaultRouterStateSerializer, } from './serializer';
//# sourceMappingURL=index.js.map

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

import { ModuleWithProviders, InjectionToken } from '@angular/core';
import { NavigationCancel, NavigationError, Router, RouterStateSnapshot, RoutesRecognized } from '@angular/router';

@@ -69,2 +70,10 @@ import { Store } from '@ngrx/store';

export declare function routerReducer<T = RouterStateSnapshot>(state: RouterReducerState<T>, action: RouterAction<any>): RouterReducerState<T>;
export declare type StoreRouterConfig = {
stateKey?: string;
};
export declare const _ROUTER_CONFIG: InjectionToken<{}>;
export declare const ROUTER_CONFIG: InjectionToken<{}>;
export declare const DEFAULT_ROUTER_FEATURENAME = "routerReducer";
export declare function _createDefaultRouterConfig(config: any): StoreRouterConfig;
export declare type StoreRouterConfigFunction = () => StoreRouterConfig;
/**

@@ -116,2 +125,4 @@ * Connects RouterModule with StoreModule.

private serializer;
private config;
static forRoot(config?: StoreRouterConfig | StoreRouterConfigFunction): ModuleWithProviders;
private routerState;

@@ -122,3 +133,4 @@ private storeState;

private navigationTriggeredByDispatch;
constructor(store: Store<any>, router: Router, serializer: RouterStateSerializer<RouterStateSnapshot>);
private stateKey;
constructor(store: Store<any>, router: Router, serializer: RouterStateSerializer<RouterStateSnapshot>, config: StoreRouterConfig);
private setUpBeforePreactivationHook();

@@ -125,0 +137,0 @@ private setUpStoreStateListener();

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

import { NgModule } from '@angular/core';
import { NgModule, InjectionToken, Inject, } from '@angular/core';
import { NavigationCancel, NavigationError, Router, RoutesRecognized, } from '@angular/router';

@@ -37,3 +37,17 @@ import { Store } from '@ngrx/store';

}
export const /** @type {?} */ _ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Internal Configuration');
export const /** @type {?} */ ROUTER_CONFIG = new InjectionToken('@ngrx/router-store Configuration');
export const /** @type {?} */ DEFAULT_ROUTER_FEATURENAME = 'routerReducer';
/**
* @param {?} config
* @return {?}
*/
export function _createDefaultRouterConfig(config) {
let /** @type {?} */ _config = {};
if (typeof config === 'function') {
_config = config();
}
return Object.assign({ stateKey: DEFAULT_ROUTER_FEATURENAME }, _config);
}
/**
* Connects RouterModule with StoreModule.

@@ -85,9 +99,12 @@ *

* @param {?} serializer
* @param {?} config
*/
constructor(store, router, serializer) {
constructor(store, router, serializer, config) {
this.store = store;
this.router = router;
this.serializer = serializer;
this.config = config;
this.dispatchTriggeredByRouter = false;
this.navigationTriggeredByDispatch = false;
this.stateKey = this.config.stateKey;
this.setUpBeforePreactivationHook();

@@ -98,4 +115,21 @@ this.setUpStoreStateListener();

/**
* @param {?=} config
* @return {?}
*/
static forRoot(config = {}) {
return {
ngModule: StoreRouterConnectingModule,
providers: [
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],
};
}
/**
* @return {?}
*/
setUpBeforePreactivationHook() {

@@ -116,3 +150,3 @@ ((this.router)).hooks.beforePreactivation = (routerState) => {

});
this.store.select('routerReducer').subscribe(() => {
this.store.select(this.stateKey).subscribe(() => {
this.navigateIfNeeded();

@@ -125,3 +159,3 @@ });

shouldDispatchRouterNavigation() {
if (!this.storeState['routerReducer'])
if (!this.storeState[this.stateKey])
return true;

@@ -134,4 +168,4 @@ return !this.navigationTriggeredByDispatch;

navigateIfNeeded() {
if (!this.storeState['routerReducer'] ||
!this.storeState['routerReducer'].state) {
if (!this.storeState[this.stateKey] ||
!this.storeState[this.stateKey].state) {
return;

@@ -141,5 +175,5 @@ }

return;
if (this.router.url !== this.storeState['routerReducer'].state.url) {
if (this.router.url !== this.storeState[this.stateKey].state.url) {
this.navigationTriggeredByDispatch = true;
this.router.navigateByUrl(this.storeState['routerReducer'].state.url);
this.router.navigateByUrl(this.storeState[this.stateKey].state.url);
}

@@ -214,2 +248,11 @@ }

{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer },
{
provide: _ROUTER_CONFIG,
useValue: { stateKey: DEFAULT_ROUTER_FEATURENAME },
},
{
provide: ROUTER_CONFIG,
useFactory: _createDefaultRouterConfig,
deps: [_ROUTER_CONFIG],
},
],

@@ -225,2 +268,3 @@ },] },

{ type: RouterStateSerializer, },
{ type: undefined, decorators: [{ type: Inject, args: [ROUTER_CONFIG,] },] },
];

@@ -246,2 +290,4 @@ function StoreRouterConnectingModule_tsickle_Closure_declarations() {

/** @type {?} */
StoreRouterConnectingModule.prototype.stateKey;
/** @type {?} */
StoreRouterConnectingModule.prototype.store;

@@ -252,3 +298,5 @@ /** @type {?} */

StoreRouterConnectingModule.prototype.serializer;
/** @type {?} */
StoreRouterConnectingModule.prototype.config;
}
//# sourceMappingURL=router_store_module.js.map

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