mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Updated ngrx to 6.0.0-beta.1
This commit is contained in:
parent
a2187e0134
commit
6bf2fe0b17
6505
package-lock.json
generated
6505
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
|
@ -20,22 +20,22 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@agm/core": "1.0.0-beta.2",
|
"@agm/core": "1.0.0-beta.2",
|
||||||
"@angular/animations": "6.0.0",
|
"@angular/animations": "6.0.0",
|
||||||
"@angular/cdk": "6.0.0",
|
"@angular/cdk": "6.0.1",
|
||||||
"@angular/common": "6.0.0",
|
"@angular/common": "6.0.0",
|
||||||
"@angular/compiler": "6.0.0",
|
"@angular/compiler": "6.0.0",
|
||||||
"@angular/core": "6.0.0",
|
"@angular/core": "6.0.0",
|
||||||
"@angular/flex-layout": "6.0.0-beta.15",
|
"@angular/flex-layout": "6.0.0-beta.15",
|
||||||
"@angular/forms": "6.0.0",
|
"@angular/forms": "6.0.0",
|
||||||
"@angular/http": "6.0.0",
|
"@angular/http": "6.0.0",
|
||||||
"@angular/material": "6.0.0",
|
"@angular/material": "6.0.1",
|
||||||
"@angular/material-moment-adapter": "6.0.0",
|
"@angular/material-moment-adapter": "6.0.1",
|
||||||
"@angular/platform-browser": "6.0.0",
|
"@angular/platform-browser": "6.0.0",
|
||||||
"@angular/platform-browser-dynamic": "6.0.0",
|
"@angular/platform-browser-dynamic": "6.0.0",
|
||||||
"@angular/router": "6.0.0",
|
"@angular/router": "6.0.0",
|
||||||
"@ngrx/effects": "5.2.0",
|
"@ngrx/effects": "6.0.0-beta.1",
|
||||||
"@ngrx/router-store": "5.2.0",
|
"@ngrx/router-store": "6.0.0-beta.1",
|
||||||
"@ngrx/store": "5.2.0",
|
"@ngrx/store": "6.0.0-beta.1",
|
||||||
"@ngrx/store-devtools": "5.2.0",
|
"@ngrx/store-devtools": "6.0.0-beta.1",
|
||||||
"@ngx-translate/core": "10.0.1",
|
"@ngx-translate/core": "10.0.1",
|
||||||
"@swimlane/ngx-charts": "7.3.0",
|
"@swimlane/ngx-charts": "7.3.0",
|
||||||
"@swimlane/ngx-datatable": "11.3.2",
|
"@swimlane/ngx-datatable": "11.3.2",
|
||||||
|
|
|
@ -5,23 +5,29 @@ export const GO = '[Router] Go';
|
||||||
export const BACK = '[Router] Back';
|
export const BACK = '[Router] Back';
|
||||||
export const FORWARD = '[Router] Forward';
|
export const FORWARD = '[Router] Forward';
|
||||||
|
|
||||||
export class Go implements Action {
|
export class Go implements Action
|
||||||
readonly type = GO;
|
{
|
||||||
constructor(
|
readonly type = GO;
|
||||||
public payload: {
|
|
||||||
path: any[];
|
constructor(
|
||||||
query?: object;
|
public payload: {
|
||||||
extras?: NavigationExtras;
|
path: any[];
|
||||||
|
query?: object;
|
||||||
|
extras?: NavigationExtras;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Back implements Action {
|
export class Back implements Action
|
||||||
readonly type = BACK;
|
{
|
||||||
|
readonly type = BACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Forward implements Action {
|
export class Forward implements Action
|
||||||
readonly type = FORWARD;
|
{
|
||||||
|
readonly type = FORWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Actions = Go | Back | Forward;
|
export type Actions = Go | Back | Forward;
|
||||||
|
|
|
@ -8,28 +8,31 @@ import * as RouterActions from '../actions/router.action';
|
||||||
import { tap, map } from 'rxjs/operators';
|
import { tap, map } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RouterEffects {
|
export class RouterEffects
|
||||||
constructor(
|
{
|
||||||
private actions$: Actions,
|
constructor(
|
||||||
private router: Router,
|
private actions$: Actions,
|
||||||
private location: Location
|
private router: Router,
|
||||||
) {}
|
private location: Location
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({dispatch: false})
|
||||||
navigate$ = this.actions$.ofType(RouterActions.GO).pipe(
|
navigate$ = this.actions$.ofType(RouterActions.GO).pipe(
|
||||||
map((action: RouterActions.Go) => action.payload),
|
map((action: RouterActions.Go) => action.payload),
|
||||||
tap(({ path, query: queryParams, extras }) => {
|
tap(({path, query: queryParams, extras}) => {
|
||||||
this.router.navigate(path, { queryParams, ...extras });
|
this.router.navigate(path, {queryParams, ...extras});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({dispatch: false})
|
||||||
navigateBack$ = this.actions$
|
navigateBack$ = this.actions$
|
||||||
.ofType(RouterActions.BACK)
|
.ofType(RouterActions.BACK)
|
||||||
.pipe(tap(() => this.location.back()));
|
.pipe(tap(() => this.location.back()));
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({dispatch: false})
|
||||||
navigateForward$ = this.actions$
|
navigateForward$ = this.actions$
|
||||||
.ofType(RouterActions.FORWARD)
|
.ofType(RouterActions.FORWARD)
|
||||||
.pipe(tap(() => this.location.forward()));
|
.pipe(tap(() => this.location.forward()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,48 @@
|
||||||
import {
|
import {
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot,
|
||||||
Params,
|
Params
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { createFeatureSelector, ActionReducerMap } from '@ngrx/store';
|
import { createFeatureSelector, ActionReducerMap } from '@ngrx/store';
|
||||||
|
|
||||||
import * as fromRouter from '@ngrx/router-store';
|
import * as fromRouter from '@ngrx/router-store';
|
||||||
|
|
||||||
export interface RouterStateUrl {
|
export interface RouterStateUrl
|
||||||
url: string;
|
{
|
||||||
queryParams: Params;
|
url: string;
|
||||||
params: Params;
|
queryParams: Params;
|
||||||
|
params: Params;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface State {
|
export interface State
|
||||||
routerReducer: fromRouter.RouterReducerState<RouterStateUrl>;
|
{
|
||||||
|
routerReducer: fromRouter.RouterReducerState<RouterStateUrl>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const reducers: ActionReducerMap<State> = {
|
export const reducers: ActionReducerMap<State> = {
|
||||||
routerReducer: fromRouter.routerReducer,
|
routerReducer: fromRouter.routerReducer
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRouterState = createFeatureSelector<
|
export const getRouterState = createFeatureSelector<fromRouter.RouterReducerState<RouterStateUrl>>('routerReducer');
|
||||||
fromRouter.RouterReducerState<RouterStateUrl>
|
|
||||||
>('routerReducer');
|
|
||||||
|
|
||||||
export class CustomSerializer
|
export class CustomSerializer implements fromRouter.RouterStateSerializer<RouterStateUrl>
|
||||||
implements fromRouter.RouterStateSerializer<RouterStateUrl> {
|
{
|
||||||
serialize(routerState: RouterStateSnapshot): RouterStateUrl {
|
serialize(routerState: RouterStateSnapshot): RouterStateUrl
|
||||||
const { url } = routerState;
|
{
|
||||||
const { queryParams } = routerState.root;
|
const {url} = routerState;
|
||||||
|
const {queryParams} = routerState.root;
|
||||||
|
|
||||||
let state: ActivatedRouteSnapshot = routerState.root;
|
let state: ActivatedRouteSnapshot = routerState.root;
|
||||||
while (state.firstChild) {
|
while ( state.firstChild )
|
||||||
state = state.firstChild;
|
{
|
||||||
|
state = state.firstChild;
|
||||||
|
}
|
||||||
|
const {params} = state;
|
||||||
|
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
queryParams,
|
||||||
|
params
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const { params } = state;
|
|
||||||
|
|
||||||
return { url, queryParams, params };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user