44
loading...
This website collects cookies to deliver better user experience
ng update @ngrx/store@7
ng update @ngrx/store@8
ng update @ngrx/store@9
ng update @ngrx/store@10
ng update @ngrx/store@11
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { map, tap } from 'rxjs/operators';
import {Actions, concatLatestFrom, createEffect, ofType} from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { routerNavigatedAction } from '@ngrx/router-store';
import * as fromRoot from './reducers';
@Injectable()
export class RouterEffects {
updateTitle$ = createEffect(() =>
this.actions$.pipe(
ofType(routerNavigatedAction),
concatLatestFrom(() => this.store.select(fromRoot.selectRouteData)),
map(([, data]) => `My App - ${data['title']}`),
tap((title) => this.titleService.setTitle(title))
),
{
dispatch: false,
}
);
constructor(
private actions$: Actions,
private store: Store,
private titleService: Title
) {}
}
ng add @ngrx/store
ng update @ngrx/store