reactive-blocs
Version:
11 lines (10 loc) • 537 B
TypeScript
import { BehaviorSubject } from 'rxjs';
import { ReactiveValue } from './primitives';
export type Executor<T, A> = (execArgs: A) => Promise<T> | T;
export type Task<T, A, E extends Error> = {
result: ReactiveValue<T>;
execute(args?: A, ignoreError?: boolean): Promise<T | null>;
loading: BehaviorSubject<boolean>;
error: BehaviorSubject<E | null>;
};
export declare const createTask: <T, A, E extends Error = Error>(executor: Executor<T, A>, initialValue?: T | undefined, initialParams?: A | undefined) => Task<T, A, E>;