@o3r/core
Version:
Core of the Otter Framework
34 lines • 1.45 kB
JavaScript
import { asyncStoreItemAdapter, } from './async.adapter';
/**
* Serializer for asynchronous store.
* @param state State of an asynchronous store to serialize
* @returns a plain json object to pass to json.stringify
*/
export function asyncSerializer(state) {
return asyncStoreItemAdapter.clearAsyncStoreItem(state);
}
/**
* Serializer for asynchronous entity store.
* @param state State of an asynchronous entity store to serialize
* @returns a plain json object to pass to json.stringify
*/
export function asyncEntitySerializer(state) {
const entities = state.ids.reduce((entitiesAcc, entityId) => {
entitiesAcc[entityId] = asyncStoreItemAdapter.clearAsyncStoreItem(state.entities[entityId]);
return entitiesAcc;
}, {});
return { ...asyncStoreItemAdapter.clearAsyncStoreItem(state), entities };
}
/**
* Serializer for asynchronous entity store with status.
* @param state State of an asynchronous entity store with status to serialize
* @returns a plain json object to pass to json.stringify
*/
export function asyncEntityWithStatusSerializer(state) {
const entities = state.ids.reduce((entitiesAcc, entityId) => {
entitiesAcc[entityId] = { ...asyncStoreItemAdapter.clearAsyncStoreItem(state.entities[entityId]), status: {} };
return entitiesAcc;
}, {});
return { ...asyncStoreItemAdapter.clearAsyncStoreItem(state), entities };
}
//# sourceMappingURL=async.serializer.js.map