import { Injector } from '@angular/core'; import { Observable } from 'rxjs'; type RxMethodRef = { destroy: () => void; }; type RxMethod = ((input: Input | (() => Input) | Observable, config?: { injector?: Injector; }) => RxMethodRef) & RxMethodRef; /** * @description * * Creates a reactive method for managing side effects by utilizing RxJS APIs. * The method accepts an observable, a signal, a computation function, or * a static value. * * @usageNotes * * ```ts * import { Component, inject, signal } from '@angular/core'; * import { switchMap } from 'rxjs'; * import { rxMethod } from '@ngrx/signals/rxjs-interop'; * import { tapResponse } from '@ngrx/operators'; * * \@Component(...) * export class TodoList { * readonly #todosService = inject(TodosService); * readonly userId = signal(1); * readonly todos = signal([]); * * readonly loadTodos = rxMethod( * switchMap((id) => * this.#todosService.getByUserId(id).pipe( * tapResponse({ * next: (todos) => this.todos.set(todos), * error: console.error, * }) * ) * ) * ); * * constructor() { * // 👇 Load todos on `userId` changes. * this.loadTodos(this.userId); * } * } * ``` */ declare function rxMethod(generator: (source$: Observable) => Observable, config?: { injector?: Injector; }): RxMethod; export { rxMethod }; export type { RxMethod };