Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Inject, Injectable, Optional } from '@angular/core';
- import { ActivatedRoute } from '@angular/router';
- import { Actions, Effect, ofType } from '@ngrx/effects';
- import { SchedulerLike } from 'rxjs';
- import { async } from 'rxjs/internal/scheduler/async';
- import { delay, map } from 'rxjs/operators';
- import { CreateTripInformationFromQuery } from '../actions';
- import { LoadTripOverview, PageLoadActionTypes } from '../actions/page-load.actions';
- export const DELAY_TIME: number = 20;
- @Injectable()
- export class TripInformationEffects {
- constructor(
- private actions$: Actions,
- private activatedRoute: ActivatedRoute,
- @Optional() @Inject(async) private scheduler: SchedulerLike,
- @Optional() @Inject(DELAY_TIME) private delayTime: number,
- ) {}
- /**
- * @route :country/:language->trip
- * @listen [PageLoad] Load Trip Overview
- * @dispatch [TripInformation] Create form query
- */
- /* tslint:disable:member-ordering */
- @Effect()
- public loadTripOverview$ = this.actions$.pipe(
- ofType<LoadTripOverview>(PageLoadActionTypes.LoadTripOverview),
- map(() => new CreateTripInformationFromQuery(this.activatedRoute.snapshot.queryParams))
- );
- @Effect()
- public loadTripOverviewDelay$ = this.actions$.pipe(
- ofType<LoadTripOverview>(PageLoadActionTypes.LoadTripOverview),
- delay(this.delayTime, this.scheduler),
- map(() => new CreateTripInformationFromQuery(this.activatedRoute.snapshot.queryParams))
- );
- }
Add Comment
Please, Sign In to add comment