@snipsonian/observable-state
Version:
Observable-state snippets (redux-like)
18 lines (17 loc) • 2.21 kB
TypeScript
import { IActionableObservableStateStore } from '../types';
import { TEntityKey, ITriggerAsyncEntityFetchProps, ITriggerAsyncEntityCreateProps, ITriggerAsyncEntityUpdateProps, ITriggerAsyncEntityRemoveProps, IAsyncEntityOperationNotificationProps, IAsyncEntityTriggerResolveValue } from './types';
import { IAsyncEntityActionCreators } from './asyncEntityActionCreators';
interface IAsyncEntityTriggers<State, StateChangeNotificationKey> {
fetch: <ApiInput, ApiResult, ApiResponse = ApiResult>(props: ITriggerAsyncEntityFetchProps<State, ApiInput, StateChangeNotificationKey, ApiResult, ApiResponse> & IAsyncEntityTriggerBaseInput<StateChangeNotificationKey>) => Promise<IAsyncEntityTriggerResolveValue<ApiResult>>;
create: <ApiInput, ApiResult, ApiResponse = ApiResult>(props: ITriggerAsyncEntityCreateProps<State, ApiInput, StateChangeNotificationKey, ApiResult, ApiResponse> & IAsyncEntityTriggerBaseInput<StateChangeNotificationKey>) => Promise<IAsyncEntityTriggerResolveValue<ApiResult>>;
update: <ApiInput, ApiResult, ApiResponse = ApiResult>(props: ITriggerAsyncEntityUpdateProps<State, ApiInput, StateChangeNotificationKey, ApiResult, ApiResponse> & IAsyncEntityTriggerBaseInput<StateChangeNotificationKey>) => Promise<IAsyncEntityTriggerResolveValue<ApiResult>>;
remove: <ApiInput, ApiResult, ApiResponse = ApiResult>(props: ITriggerAsyncEntityRemoveProps<State, ApiInput, StateChangeNotificationKey, ApiResult, ApiResponse> & IAsyncEntityTriggerBaseInput<StateChangeNotificationKey>) => Promise<IAsyncEntityTriggerResolveValue<ApiResult>>;
}
interface IAsyncEntityTriggerBaseInput<StateChangeNotificationKey> extends Required<IAsyncEntityOperationNotificationProps<StateChangeNotificationKey>> {
asyncEntityKey: TEntityKey;
}
export declare function initAsyncEntityTriggers<State, ExtraProcessInput, StateChangeNotificationKey, Error, ActionType>({ asyncEntityActionCreators, getStore, }: {
asyncEntityActionCreators: IAsyncEntityActionCreators<State, ExtraProcessInput, StateChangeNotificationKey, Error, ActionType>;
getStore: () => IActionableObservableStateStore<State, StateChangeNotificationKey>;
}): IAsyncEntityTriggers<State, StateChangeNotificationKey>;
export {};