add bool factory
This commit is contained in:
parent
918326d4fe
commit
b662479794
@ -27,3 +27,12 @@ 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>[] {
|
||||
const result = obs.pipe(map(project), shareDistinctLast());
|
||||
const inverse = result.pipe(
|
||||
map(value => !value),
|
||||
shareDistinctLast(),
|
||||
);
|
||||
return [result, inverse];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user