UNPKG

@data-client/core

Version:

Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch

21 lines (17 loc) 448 B
import type { State, ExpireAllAction } from '../../types.js'; export function expireReducer(state: State<unknown>, action: ExpireAllAction) { const meta = { ...state.meta }; Object.keys(meta).forEach(key => { if (action.testKey(key)) { meta[key] = { ...meta[key], // 1 instead of 0 so we can do 'falsy' checks to see if it is set expiresAt: 1, }; } }); return { ...state, meta, }; }