Skip to content

ChimericSyncReducer

Available from @chimeric/react.

Combines up to 10 ChimericSync services into a single ChimericSync.

import { ChimericSyncReducer } from '@chimeric/react';
const getDashboardCounts = ChimericSyncReducer<void>().build({
serviceList: [
{ service: getActiveCount },
{ service: getArchivedCount },
],
reducer: ([active, archived]) => ({
active,
archived,
total: active + archived,
}),
});
// Idiomatic
const counts = getDashboardCounts();
// Reactive
const counts = getDashboardCounts.useHook();
PropertyTypeDescription
serviceListArray of { service, getParams? }Up to 10 ChimericSync services
reducer(results[], params) => TResultCombines all service results

Each service config:

PropertyTypeDescription
serviceChimericSync<TParams, TResult>The sync service
getParams(serviceParams) => TParamsOptional param transformer. Omit if the service takes void.

IdiomaticSyncReducer and ReactiveSyncReducer are also available for single-path usage.