@magnetarjs/plugin-vue3
Version: 
Magnetar plugin vue3
14 lines (13 loc) • 597 B
JavaScript
import { getPathWhereIdentifier } from '@magnetarjs/types';
export function fetchCountActionFactory(pathCountDic, vue3StoreOptions) {
    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;
    };
}