Architecture Decisions - action-land/action-land GitHub Wiki

1. Remove oState from ComponentProps (26 Sep 2019)

Issue

Calling multiple matchR on component transforms oState to union of similar states, which causes issues like one explained in example below while applying operators like fold and reduce

import {ComponentNext} from '@action-land/component'
const componentA = ComponentNext.lift({count: 10})
  .matchR('type1', (cb, s) => {
    return {
      ...s,
      count1: 10
    }
  })
  .render((_, p: {id: string}) => p.id)
  .toList(p => p.id)

const componentB = ComponentNext.lift({a: 10})
  .install({
    b: componentA
  })
  .render((_, p) => {
    // _.state.children.b is oState of componentA
    // TypeError: This expression is not callable.
    // Each member of the union type '(<T>(s: T, fn: (current: { count: number; }, k: string | number, acc: T) => T) => T) | (<T>(s: T, fn: (current: { count1: number; count: number; }, k: string | number, acc: T) => T) => T)' has signatures, but none of those signatures are compatible with each other
    _.state.children.b.fold([], (current, a, s) => {})
  })