author Ben Hayward
  import { Injectable } from '@angular/core' ; import { CanActivate , Router , ChildActivationEnd } from '@angular/router' ; import { WalletTabHistoryService } from '../tab-history.service' ; import { filter , take } from 'rxjs/operators' ; @ Injectable ( ) export class TabStorageGuard implements CanActivate { constructor ( private tabHistory , private router ) { } returns canActivate ( ) { this . router . events . pipe ( filter ( event => event instanceof ChildActivationEnd ) , take ( 1 ) ) . subscribe ( ( event ) => { const url = event . snapshot [ '_routerState' ] . url ; const splitUrl = url . split ( '/wallet' ) [ 1 ] ; if ( splitUrl ) { this . tabHistory . lastTab = splitUrl ; } } ) ; return true ; } }