Created
February 8, 2020 04:55
-
-
Save alexytiger/74016754667f965f88a0e345d6a82be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { createEffect } from '@ngrx/effects'; | |
import { tap, map } from 'rxjs/operators'; | |
import * as fromStore from '../reducers'; | |
import { Store, select } from '@ngrx/store'; | |
import { SpinnerOverlayService } from '../../services/spinner-overlay.service'; | |
@Injectable() | |
export class SpinnerEffects { | |
constructor( | |
private store$: Store<fromStore.AppState>, | |
private spinner: SpinnerOverlayService) {} | |
handleSpinner$ = createEffect( | |
() => | |
this.store$.pipe( | |
select(fromStore.getSpinnerShow), | |
tap( isShow => | |
isShow ? this.spinner.show() : this.spinner.hide() | |
)), | |
{ dispatch: false } | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment