Appearance
Appearance
Emits only the values that pass a given predicate function — all others are silently dropped.
filter<T>(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction<T>source: --1----2----3----4----|
filter(x => x % 2 === 0)
result: -------2---------4----|
import { from } from 'rxjs'
import { filter } from 'rxjs/operators'
from([1, 2, 3, 4, 5]).pipe(
filter(x => x % 2 === 0)
).subscribe(console.log)
// Output: 2, 4