UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

46 lines (45 loc) 2.15 kB
import type { AnyAction } from 'redux'; import type { ServerError } from '@mattermost/types/errors'; import type { GlobalState } from '@mattermost/types/store'; import type { DispatchFunc, GetStateFunc, ActionFuncAsync } from 'mattermost-redux/types/actions'; type ActionType = string; export declare function forceLogoutIfNecessary(err: ServerError, dispatch: DispatchFunc<AnyAction>, getState: GetStateFunc): void; export declare function requestData(type: ActionType): { type: string; data: null; }; export declare function requestSuccess(type: ActionType, data: any): { type: string; data: any; }; export declare function requestFailure(type: ActionType, error: ServerError): any; /** * Returns an ActionFunc which calls a specfied (client) function and * dispatches the specifed actions on request, success or failure. * * @export * @param {Object} obj an object for destructirung required properties * @param {() => Promise<mixed>} obj.clientFunc clientFunc to execute * @param {ActionType} obj.onRequest ActionType to dispatch on request * @param {(ActionType | Array<ActionType>)} obj.onSuccess ActionType to dispatch on success * @param {ActionType} obj.onFailure ActionType to dispatch on failure * @param {...Array<any>} obj.params * @returns {ActionFunc} ActionFunc */ export declare function bindClientFunc<Func extends (...args: any[]) => Promise<any>>({ clientFunc, onRequest, onSuccess, onFailure, params, }: { clientFunc: Func; onRequest?: ActionType; onSuccess?: ActionType | ActionType[]; onFailure?: ActionType; params?: Parameters<Func>; }): ActionFuncAsync<Awaited<ReturnType<Func>>, GlobalState, AnyAction>; export declare function debounce(func: (...args: any) => unknown, wait: number, immediate?: boolean, cb?: () => unknown): (...args: any[]) => void; export declare class FormattedError extends Error { intl: { id: string; defaultMessage: string; values: any; }; constructor(id: string, defaultMessage: string, values?: any); } export {};