rxMethod for Async Work
Handle async flows with rxMethod.
Async In SignalStore
Many actions are asynchronous: loading data, debounced search, polling. SignalStore offers rxMethod to manage these reactive, cancellable async flows.
rxMethod Basics
rxMethod creates a method backed by an RxJS pipeline. You call it with a value (or a signal/observable) and it pushes into the stream.
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { pipe, switchMap, tap } from 'rxjs';
withMethods((store, api = inject(Api)) => ({
load: rxMethod<string>(pipe(
switchMap(id => api.getById(id)),
tap(item => patchState(store, { current: item }))
))
}))All lessons in this course
- Creating a SignalStore
- Computed and Methods
- rxMethod for Async Work
- Entities and Custom Features