API Reference / @dasch-ng/rxjs-operators / filterString
Function: filterString()
filterString(): (
source$) =>Observable<string>
Defined in: filter-string.ts:23
Filters values to only allow strings, with proper TypeScript type narrowing.
This operator removes all non-string values from the observable stream and narrows the type to string, ensuring type safety in TypeScript.
Returns
An operator function that filters to only string values
(
source$):Observable<string>
Parameters
source$
Observable<unknown>
Returns
Observable<string>
Example
typescript
import { of } from 'rxjs';
import { filterString } from '@dasch-ng/rxjs-operators';
of('hello', 42, 'world', true, 'test')
.pipe(filterString())
.subscribe(console.log);
// Output: 'hello', 'world', 'test'