import type { ReduxAction } from "./types"; /** * Transforms the action into the same type with `meta.isLoading` set to true. * * @template [P=any] The payload type for the given action * @param {ReduxAction
} action The action to be transformed into the pending version of itself * @returns {ReduxAction
} The pending action */ export const asPending =
(action: ReduxAction
): ReduxAction
=> ({ ...action, meta: { ...action.meta, isLoading: true, }, }); /** * Transforms the action into the same type with `error` set to true. * * @template [P=any] The payload type for the given action * @param {ReduxAction
} action The action to be transformed into the error version of itself * @returns {ReduxAction
} The error action */ export const asError =
(action: ReduxAction
): ReduxAction
=> ({ ...action, error: true, });