UNPKG

@magnetarjs/plugin-simple-store

Version:
14 lines (13 loc) 599 B
import { getPathWhereIdentifier } from '@magnetarjs/types'; export function fetchCountActionFactory(pathCountDic, simpleStoreOptions) { return function ({ collectionPath, actionConfig, pluginModuleConfig, }) { const pathId = getPathWhereIdentifier(collectionPath, pluginModuleConfig); const doOnFetchAggregateAction = (count) => { // abort updating local cache state if the payload was set to undefined if (count === undefined) return; pathCountDic[pathId] = count; }; return doOnFetchAggregateAction; }; }