import { Effect , Actions , ofType } from '@ngrx/effects' ; import { Injectable } from '@angular/core' ; import { map } from 'rxjs/operators' ; import { AppActionTypes , LogoutAction , ReloadDocumentListAction , ResetSelectionAction } from '@alfresco/aca-shared/store' ; import { AuthenticationService } from '@alfresco/adf-core' ; import { Router } from '@angular/router' ; import { AppHookService } from '@alfresco/aca-shared' ; @ Injectable ( ) export class AppEffects { constructor ( private actions$ , private auth , private router , private appHookService ) { } @ Effect ( { dispatch : false } ) reload = this . actions$ . pipe ( ofType < ReloadDocumentListAction > ( AppActionTypes . ReloadDocumentList ) , map ( ( action ) => { this . appHookService . reload . next ( action ) ; } ) ) ; @ Effect ( { dispatch : false } ) resetSelection = this . actions$ . pipe ( ofType < ResetSelectionAction > ( AppActionTypes . ResetSelection ) , map ( ( action ) => { this . appHookService . reset . next ( action ) ; } ) ) ; @ Effect ( { dispatch : false } ) logout$ = this . actions$ . pipe ( ofType < LogoutAction > ( AppActionTypes . Logout ) , map ( ( ) => { this . auth . logout ( ) . subscribe ( ( ) => this . redirectToLogin ( ) , ( ) => this . redirectToLogin ( ) ) ; } ) ) ; private redirectToLogin ( ) { return this . router . navigate ( [ 'login' ] ) ; } }