UNPKG

@bhupinderanand/react-redux-saga-boilerplate

Version:
23 lines (17 loc) 583 B
import { now } from '@gilbarbara/helpers'; import { createAction } from '@reduxjs/toolkit'; import { REHYDRATE } from 'redux-persist'; import { RootState } from 'types'; export function actionPayload<T = any, M = Record<string, string>>(payload: T, meta?: M) { return { payload, meta }; } /** * Check if cache is valid */ export function hasValidCache(lastUpdated: number, max = 10): boolean { if (!navigator.onLine) { return true; } return lastUpdated + max * 60 > now(); } export const rehydrateAction = createAction<RootState>(REHYDRATE);