MCPcopy Create free account
hub / github.com/angular/angular / CompletesBeforeEmitting

Class CompletesBeforeEmitting

packages/router/test/integration/guards.spec.ts:83–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 describe('CanActivate', () => {
82 describe('guard completes before emitting a value', () => {
83 @Injectable({providedIn: 'root'})
84 class CompletesBeforeEmitting {
85 private subject$ = new Subject<boolean>();
86
87 constructor(destroyRef: DestroyRef) {
88 destroyRef.onDestroy(() => this.subject$.complete());
89 }
90
91 // Note that this is a simple illustrative case of when an observable
92 // completes without emitting a value. In a real-world scenario, this
93 // might represent an HTTP request that never emits before the app is
94 // destroyed and then completes when the app is destroyed.
95 canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
96 return this.subject$;
97 }
98 }
99
100 it('should not thrown an unhandled promise rejection', async () => {
101 const router = TestBed.inject(Router);

Callers

nothing calls this directly

Calls 1

InjectableInterface · 0.90

Tested by

no test coverage detected