Types

createApis

/**
 * @arg {string} path Request URL path
 * @arg {*} payload Request payload. Omit if method is GET.
 * @arg {object} options Axios options
 *
 * @returns {Promise<AxiosResponse>}
 */
interface makeRequest {
    (path: string, ...rest: any[]): Promise<AxiosResponse>;
}

interface AxiosWrapperInstance {
    get: makeRequest;
    put: makeRequest;
    patch: makeRequest;
    post: makeRequest;
    delete: makeRequest;
    addAuthorization: {
        (authorization: string): void;
    };
    removeAuthorization: {
        (): void;
    };
    addHeader: {
        (name: string, value: string): void;
    };
    removeHeader: {
        (name: string): void;
    };
    instance: AxiosInstance;
}


/**
 * @arg {string} path URL Path
 * @arg {any} payload Request payload. Skip if GET.
 * @arg {function} success Success action
 * @arg {function} fail Fail action
 * @arg {function} done? Done action
 */
interface makeCall {
    (path: string, ...rest: any[]): Promise<AxiosResponse>;
}

interface SagaApiInstance {
    get: makeCall;
    post: makeCall;
    put: makeCall;
    patch: makeCall;
    delete: makeCall;
}

/**
 * @param {AxiosRequestConfig} options Axios configuration
 */
declare const createApis: (options: AxiosRequestConfig) => {
    api: AxiosWrapperInstance;
    sagaApi: SagaApiInstance;
};

refetch

  • Fetch whatever is in state.current again in order to refresh a resource after an association or other out of context action.

crudSaga

  • Creates crud saga boilerplate clojure for sagas slice

crudInitialState

  • Creates an opinionated initial state for handling common CRUD operates

crudReducers

  • Creates an opinionated reducer object for handling common CRUD operations

crudSlice

  • Creates a saga slice with opinionated CRUD functionality

Last updated

Was this helpful?