0Pricing
Angular Academy · Lesson

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

  1. Creating a SignalStore
  2. Computed and Methods
  3. rxMethod for Async Work
  4. Entities and Custom Features
← Back to Angular Academy