import { Subscription, BehaviorSubject } from 'rxjs'; import { ProcessLifecycleCallbacks } from '@rxfx/service'; type UseServiceOptions = { /** What to do when component unmounts */ unmount?: 'cancelCurrent' | 'cancelCurrentAndQueued'; }; /** Only the bits of Service that useService actually needs */ export interface UsableAsService { /** fire off a request */ request(req: TRequest): void; /** cancel only the in-flight request */ cancelCurrent(): void; /** cancel in-flight + queued requests */ cancelCurrentAndQueued(): void; /** the current value + subscription */ state: BehaviorSubject; /** whether any handler is active */ isActive: BehaviorSubject; /** last error or null */ currentError: BehaviorSubject; /** allows callbacks to be run upon ProcessLifecycleEvents */ observe(cbs: Partial>): Subscription; } /** Provides updates to state, isActive, and currentError populated from the service. * Allows requesting of the service via `request`. Optionally cancels requests on unmount. * Works with both Services and Effects. * @param service - The service to connect to * @param options - Configuration including unmount behavior * @returns An object with fields to access the state and status of the Service/Effect */ export declare function useService(service: UsableAsService, options?: UseServiceOptions): { state: TState; request: (req: TRequest) => void; isActive: boolean; isLoading: boolean; currentError: TError | null; }; /** Alias for useService, for working with an @rxfx/effect * @see useService */ export declare function useFx(service: UsableAsService, options?: UseServiceOptions): { state: TState; request: (req: TRequest) => void; isActive: boolean; isLoading: boolean; currentError: TError | null; }; export {};