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
// NgRx v7.3.0 | |
describe('Auth Guard', () => { | |
let guard: AuthGuard; | |
let store: Store<any>; | |
beforeEach(() => { | |
TestBed.configureTestingModule({ | |
imports: [ | |
StoreModule.forRoot({ | |
...fromRoot.reducers, |
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
// NgRx v7.3.0 | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class AuthGuard implements CanActivate { | |
constructor(private store: Store<fromAuth.State>) {} | |
canActivate(): Observable<boolean> { | |
return this.store.pipe( | |
select(fromAuth.getLoggedIn), |
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 { Component } from '@angular/core'; | |
import { MatDialog } from '@angular/material'; | |
@Component({ | |
selector: 'dialog-overview-example', | |
template: `<a (click)="openDialog()">Open Dialog</a>` | |
}) | |
export class DialogOverviewExample { | |
constructor(public dialog: MatDialog) {} |
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
// -- error.actions.ts -- | |
export class LaunchErrorModal implements Action { | |
readonly type = ErrorActions.LaunchErrorModal; | |
} | |
export class MarkErrorModalAsOpen implements Action { | |
readonly type = ErrorActions.MarkErrorModalAsOpen; | |
} | |
export class CloseErrorModal implements Action { |
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
// -- error.actions.ts -- | |
export class LaunchErrorModal implements Action { | |
readonly type = ErrorActions.LaunchErrorModal; | |
} | |
// -- error.effects.ts -- | |
@Effect({ dispatch: false }) | |
launchErrorModal$: Observable<Action> = this.actions$.pipe( | |
ofType<LaunchErrorModal>(ErrorActions.LaunchErrorModal), | |
tap(() => this.dialog.open(ErrorModalComponent)) |