MCPcopy Index your code
hub / github.com/angular/angular / CompletesBeforeEmitting

Class CompletesBeforeEmitting

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

InjectableInterface · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…