UNPKG

ngx-http-request-state

Version:

Angular library for wrapping HttpClient responses with loading & error information to allow observing load/loading/error state changes as a stream of events.

24 lines (23 loc) 1.07 kB
import { ErrorState, ErrorStateWithValue, LoadedState, LoadingState, LoadingStateWithValue } from './model'; import { HttpErrorResponse } from '@angular/common/http'; /** * Returns a new LoadingState instance with an optional last-known value. * * @param value may be provided to indicate the previously-loaded, or last-known, state */ export declare function loadingState<T>(value: T): LoadingStateWithValue<T>; export declare function loadingState<T = never>(): LoadingState<T>; /** * Returns a new LoadedState instance, with the optional value as the loaded data. * * @param value */ export declare function loadedState<T>(value: T): LoadedState<T>; /** * Returns a new ErrorState instance with the given error and optional last-known value. * * @param error * @param value may be provided to indicate the previously-loaded, or last-known, state */ export declare function errorState<T>(error: HttpErrorResponse | Error, value: T): ErrorStateWithValue<T>; export declare function errorState<T = never>(error: HttpErrorResponse | Error): ErrorState<T>;