Skip to content

filter()

Function

filter<T>(filterFn: Function): CancellingPipeOperator<T, T>

Prevents emission of a value in the observable chain, if the value does not pass the test in the filterFn.

ts
declare const read1: Read<string>;
const read: Read<string, true> = read1.pipe(filter((value: string) => value !== 'allowed'));

Using this operator in a chain, results in the resulting Read to be a cancelling Read.

Observable Behavior:

Works exactly like filter of RxJS.

Sync Behavior:

Checks the value with the filterFn. If it passes the check the chain will continue, if not it will be canceled.

Source: lib/operators/filter.operator.ts:28

Type parameters

ParameterDescription
Ttype of the value

Parameters

ParameterTypeDescription
filterFn(value: T) => booleanfunction used for filtering

Returns

CancellingPipeOperator<T, T>