Skip to content

API Reference


API Reference / @dasch-ng/rxjs-operators / filterEmpty

Function: filterEmpty()

filterEmpty<T>(): UnaryFunction<Observable<T | null | undefined>, Observable<T>>

Defined in: filter-empty.ts:24

Filters out empty values using @fxts/core's isEmpty function.

This removes empty strings, arrays, objects, Maps, and Sets, as well as null and undefined. Uses the isEmpty function from @fxts/core to determine if a value should be filtered out.

Type Parameters

T

T

The type of values emitted by the source observable

Returns

UnaryFunction<Observable<T | null | undefined>, Observable<T>>

An operator function that filters out empty values

Example

typescript
import { of } from 'rxjs';
import { filterEmpty } from '@dasch-ng/rxjs-operators';

of('hello', '', 'world', null, undefined, [], {})
  .pipe(filterEmpty())
  .subscribe(console.log);
// Output: 'hello', 'world'

Released under the MIT License.