improve boolFactory return type

This commit is contained in:
Dan Percic 2022-04-21 14:27:43 +03:00
parent 62e828db37
commit 786c43c150

View File

@ -29,7 +29,10 @@ export function shareDistinctLast<T>(values = 1): UnaryFunction<Observable<T>, O
export const toLengthValue = (entities: unknown[]): number => entities?.length ?? 0;
export const getLength = pipe(map(toLengthValue), distinctUntilChanged());
export function boolFactory<T = boolean>(obs: Observable<T>, project: (value: T) => boolean = value => !!value): Observable<boolean>[] {
export function boolFactory<T = boolean>(
obs: Observable<T>,
project: (value: T) => boolean = value => !!value,
): readonly [Observable<boolean>, Observable<boolean>] {
const result = obs.pipe(map(project), shareDistinctLast());
const inverse = result.pipe(