Hyperlinkv0.8.0-beta.28

Record

Record.makeReducerUnionfunctioneffect/Record.ts:1476
<K extends string, A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<
  Record<K, A>
>

Creates a Reducer for combining Records using union, with values for keys that exist in both records combined using the provided Combiner.

When to use

Use to build a reusable reducer for accumulating many records into one union-shaped record, preserving keys from every input and combining overlapping values with the supplied combiner.

Details

The returned reducer uses Record.union for combine and an empty record as initialValue, so the default combineAll folds from {} and accumulates keys from each input record.

Source effect/Record.ts:14766 lines
export function makeReducerUnion<K extends string, A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<Record<K, A>> {
  return Reducer.make<Record<K, A>>(
    (self, that) => union(self, that, combiner.combine),
    {} as Record<K, A>
  )
}