mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +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": {
|
||||
"@agm/core": "1.0.0-beta.2",
|
||||
"@angular/animations": "6.0.0",
|
||||
"@angular/cdk": "6.0.0",
|
||||
"@angular/cdk": "6.0.1",
|
||||
"@angular/common": "6.0.0",
|
||||
"@angular/compiler": "6.0.0",
|
||||
"@angular/core": "6.0.0",
|
||||
"@angular/flex-layout": "6.0.0-beta.15",
|
||||
"@angular/forms": "6.0.0",
|
||||
"@angular/http": "6.0.0",
|
||||
"@angular/material": "6.0.0",
|
||||
"@angular/material-moment-adapter": "6.0.0",
|
||||
"@angular/material": "6.0.1",
|
||||
"@angular/material-moment-adapter": "6.0.1",
|
||||
"@angular/platform-browser": "6.0.0",
|
||||
"@angular/platform-browser-dynamic": "6.0.0",
|
||||
"@angular/router": "6.0.0",
|
||||
"@ngrx/effects": "5.2.0",
|
||||
"@ngrx/router-store": "5.2.0",
|
||||
"@ngrx/store": "5.2.0",
|
||||
"@ngrx/store-devtools": "5.2.0",
|
||||
"@ngrx/effects": "6.0.0-beta.1",
|
||||
"@ngrx/router-store": "6.0.0-beta.1",
|
||||
"@ngrx/store": "6.0.0-beta.1",
|
||||
"@ngrx/store-devtools": "6.0.0-beta.1",
|
||||
"@ngx-translate/core": "10.0.1",
|
||||
"@swimlane/ngx-charts": "7.3.0",
|
||||
"@swimlane/ngx-datatable": "11.3.2",
|
||||
|
|
|
@ -5,22 +5,28 @@ export const GO = '[Router] Go';
|
|||
export const BACK = '[Router] Back';
|
||||
export const FORWARD = '[Router] Forward';
|
||||
|
||||
export class Go implements Action {
|
||||
export class Go implements Action
|
||||
{
|
||||
readonly type = GO;
|
||||
|
||||
constructor(
|
||||
public payload: {
|
||||
path: any[];
|
||||
query?: object;
|
||||
extras?: NavigationExtras;
|
||||
}
|
||||
) {}
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
export class Back implements Action {
|
||||
export class Back implements Action
|
||||
{
|
||||
readonly type = BACK;
|
||||
}
|
||||
|
||||
export class Forward implements Action {
|
||||
export class Forward implements Action
|
||||
{
|
||||
readonly type = FORWARD;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,27 +8,30 @@ import * as RouterActions from '../actions/router.action';
|
|||
import { tap, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class RouterEffects {
|
||||
export class RouterEffects
|
||||
{
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private router: Router,
|
||||
private location: Location
|
||||
) {}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
navigate$ = this.actions$.ofType(RouterActions.GO).pipe(
|
||||
map((action: RouterActions.Go) => action.payload),
|
||||
tap(({ path, query: queryParams, extras }) => {
|
||||
this.router.navigate(path, { queryParams, ...extras });
|
||||
tap(({path, query: queryParams, extras}) => {
|
||||
this.router.navigate(path, {queryParams, ...extras});
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
navigateBack$ = this.actions$
|
||||
.ofType(RouterActions.BACK)
|
||||
.pipe(tap(() => this.location.back()));
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
navigateForward$ = this.actions$
|
||||
.ofType(RouterActions.FORWARD)
|
||||
.pipe(tap(() => this.location.forward()));
|
||||
|
|
|
@ -1,42 +1,48 @@
|
|||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
Params,
|
||||
Params
|
||||
} from '@angular/router';
|
||||
import { createFeatureSelector, ActionReducerMap } from '@ngrx/store';
|
||||
|
||||
import * as fromRouter from '@ngrx/router-store';
|
||||
|
||||
export interface RouterStateUrl {
|
||||
export interface RouterStateUrl
|
||||
{
|
||||
url: string;
|
||||
queryParams: Params;
|
||||
params: Params;
|
||||
}
|
||||
|
||||
export interface State {
|
||||
export interface State
|
||||
{
|
||||
routerReducer: fromRouter.RouterReducerState<RouterStateUrl>;
|
||||
}
|
||||
|
||||
export const reducers: ActionReducerMap<State> = {
|
||||
routerReducer: fromRouter.routerReducer,
|
||||
routerReducer: fromRouter.routerReducer
|
||||
};
|
||||
|
||||
export const getRouterState = createFeatureSelector<
|
||||
fromRouter.RouterReducerState<RouterStateUrl>
|
||||
>('routerReducer');
|
||||
export const getRouterState = createFeatureSelector<fromRouter.RouterReducerState<RouterStateUrl>>('routerReducer');
|
||||
|
||||
export class CustomSerializer
|
||||
implements fromRouter.RouterStateSerializer<RouterStateUrl> {
|
||||
serialize(routerState: RouterStateSnapshot): RouterStateUrl {
|
||||
const { url } = routerState;
|
||||
const { queryParams } = routerState.root;
|
||||
export class CustomSerializer implements fromRouter.RouterStateSerializer<RouterStateUrl>
|
||||
{
|
||||
serialize(routerState: RouterStateSnapshot): RouterStateUrl
|
||||
{
|
||||
const {url} = routerState;
|
||||
const {queryParams} = routerState.root;
|
||||
|
||||
let state: ActivatedRouteSnapshot = routerState.root;
|
||||
while (state.firstChild) {
|
||||
while ( state.firstChild )
|
||||
{
|
||||
state = state.firstChild;
|
||||
}
|
||||
const { params } = state;
|
||||
const {params} = state;
|
||||
|
||||
return { url, queryParams, params };
|
||||
return {
|
||||
url,
|
||||
queryParams,
|
||||
params
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user