update bool factory

This commit is contained in:
Dan Percic 2022-02-02 14:27:17 +02:00
parent b662479794
commit b808e4661e

View File

@ -28,8 +28,9 @@ 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>(obs: Observable<T>, project: (value: T) => boolean): Observable<boolean>[] {
export function boolFactory<T = boolean>(obs: Observable<T>, project: (value: T) => boolean = value => !!value): Observable<boolean>[] {
const result = obs.pipe(map(project), shareDistinctLast());
const inverse = result.pipe(
map(value => !value),
shareDistinctLast(),