View auth-guard.service.spec.ts
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, |
View auth-guard.service.ts
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), |
View dialog-overview-example.ts
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) {} |
View ngrx-step2.ts
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 { |
View ngrx-step1.ts
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)) |