@o3r/core
Version:
Core of the Otter Framework
22 lines • 1.94 kB
TypeScript
import { Action } from '@ngrx/store';
import { Observable, OperatorFunction } from 'rxjs';
import { AsyncRequest, ExtractFromApiActionPayloadType, FromApiActionPayload } from './async.interfaces';
/**
* Custom operator to use instead of SwitchMap with effects based on FromApi actions.
* It makes sure to emit an action when the inner subscription is unsubscribed in order to keep the store up-to-date with pending information.
* @param successHandler function that returns the action to emit in case the FromApi call is a success
* @param errorHandler function that returns the action to emit in case the FromApi call fails
* @param cancelRequestActionFactory function that returns the action to emit in case the FromApi action is 'cancelled' because a new action was received by the switchMap
*/
export declare function fromApiEffectSwitchMap<T extends FromApiActionPayload<any>, S extends ExtractFromApiActionPayloadType<T>, U extends Action, V extends Action, W extends Action>(successHandler: (result: S, action: T) => U | Observable<U> | Promise<U>, errorHandler?: (error: any, action: T) => Observable<V>, cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W): OperatorFunction<T, U | V | W>;
/**
* Same as {@link fromApiEffectSwitchMap}, instead one inner subscription is kept by id.
* @param successHandler
* @param errorHandler
* @param cancelRequestActionFactory
* @param cleanUpTimer
*/
export declare function fromApiEffectSwitchMapById<T extends FromApiActionPayload<any> & {
id: string;
}, S extends ExtractFromApiActionPayloadType<T>, U extends Action, V extends Action, W extends Action>(successHandler: (result: S, action: T) => U | Observable<U> | Promise<U>, errorHandler?: (error: any, action: T) => Observable<V>, cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W, cleanUpTimer?: number): OperatorFunction<T, U | V | W>;
//# sourceMappingURL=async.operators.d.ts.map