update bool factory
This commit is contained in:
parent
b662479794
commit
b808e4661e
@ -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 toLengthValue = (entities: unknown[]): number => entities?.length ?? 0;
|
||||||
export const getLength = pipe(map(toLengthValue), distinctUntilChanged());
|
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 result = obs.pipe(map(project), shareDistinctLast());
|
||||||
|
|
||||||
const inverse = result.pipe(
|
const inverse = result.pipe(
|
||||||
map(value => !value),
|
map(value => !value),
|
||||||
shareDistinctLast(),
|
shareDistinctLast(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user