Skip to content

Function: toSource() ​

toSource<Payload, Type>(type): (source$) => Observable<Action<Payload, Type>>

Defined in: libs/rxjs/src/lib/sources/to-source.operator.ts:25

toSource is a custom RxJS operator that converts an RxJS Observable of values of type Payload (inferred) into an observable of values of type Action<Payload, Type>. It takes one argument, type, which is the type property of the Action objects that will be emitted, and which will appear as the action type in Redux DevTools:

Action Type in Redux Devtools

Example: Converting an observable into a source ​

typescript
import { timer } from 'rxjs';
import { toSource } from '@state-adapt/rxjs';

const timer$ = timer(1000).pipe(toSource('timer$'));

timer$.subscribe(console.log);
// { type: 'timer$', payload: 0 }

Type Parameters ​

Payload ​

Payload

Type ​

Type extends string = ""

Parameters ​

type ​

Type = ...

Returns ​

(source$): Observable<Action<Payload, Type>>

Parameters ​

source$ ​

Observable<Payload>

Returns ​

Observable<Action<Payload, Type>>