diff --git a/frontend/src/app/aethel/aethel.component.ts b/frontend/src/app/aethel/aethel.component.ts index 3c52df9..dc4466d 100644 --- a/frontend/src/app/aethel/aethel.component.ts +++ b/frontend/src/app/aethel/aethel.component.ts @@ -9,7 +9,7 @@ import { faChevronRight, } from "@fortawesome/free-solid-svg-icons"; import { ActivatedRoute, Router } from "@angular/router"; -import { filterOutNonNull } from "../shared/operators/IsNonNull"; +import { isNonNull } from "../shared/operators/IsNonNull"; @Component({ selector: "pp-aethel", @@ -56,7 +56,7 @@ export class AethelComponent implements OnInit { this.route.queryParams .pipe( map((queryParams) => queryParams["query"]), - filterOutNonNull(), + isNonNull(), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef), ) diff --git a/frontend/src/app/sample/sample.component.ts b/frontend/src/app/sample/sample.component.ts index 4cba164..4d0a28a 100644 --- a/frontend/src/app/sample/sample.component.ts +++ b/frontend/src/app/sample/sample.component.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from "@angular/router"; import { AethelApiService } from "../shared/services/aethel-api.service"; import { map } from "rxjs"; import { LexicalPhrase } from "../shared/types"; -import { filterOutNonNull } from "../shared/operators/IsNonNull"; +import { isNonNull } from "../shared/operators/IsNonNull"; @Component({ selector: "pp-sample", @@ -15,7 +15,7 @@ export class SampleComponent { private sample$ = this.apiService.sampleResult$(this.sampleName); public sampleResult$ = this.sample$.pipe( map((response) => response?.result), - filterOutNonNull() + isNonNull() ); constructor( diff --git a/frontend/src/app/shared/operators/IsNonNull.spec.ts b/frontend/src/app/shared/operators/IsNonNull.spec.ts index 2385fb0..2105854 100644 --- a/frontend/src/app/shared/operators/IsNonNull.spec.ts +++ b/frontend/src/app/shared/operators/IsNonNull.spec.ts @@ -1,4 +1,4 @@ -import { filterOutNonNull } from "./IsNonNull"; +import { isNonNull } from "./IsNonNull"; import { of } from "rxjs"; interface TestInterface { @@ -12,7 +12,7 @@ describe('isNonNull', () => { const source = of('hello', null, 123, undefined, true, testObject, testArray); const expected = ['hello', 123, true, testArray, testObject]; - source.pipe(filterOutNonNull()).subscribe((value) => { + source.pipe(isNonNull()).subscribe((value) => { expect(expected.includes(value)).toBe(true); }); }); @@ -23,7 +23,7 @@ describe('isNonNull', () => { } const input: TestInterface = { myTest: 'always succeeds' }; const source = of(null, input, undefined); - source.pipe(filterOutNonNull()).subscribe((value) => { + source.pipe(isNonNull()).subscribe((value) => { // This should not compile if null/undefined are allowed to pass through. testFunction(value); }); diff --git a/frontend/src/app/shared/operators/IsNonNull.ts b/frontend/src/app/shared/operators/IsNonNull.ts index 78073a2..d70ce87 100644 --- a/frontend/src/app/shared/operators/IsNonNull.ts +++ b/frontend/src/app/shared/operators/IsNonNull.ts @@ -6,7 +6,7 @@ import { Observable, filter } from "rxjs"; * @returns An operator function that filters out null and undefined values. * @template T The type of values emitted by the observable. */ -export function filterOutNonNull(): (source: Observable) => Observable> { +export function isNonNull(): (source: Observable) => Observable> { return function(source: Observable): Observable> { return source.pipe( filter((value: T): value is NonNullable => value != null && value !== undefined)