These are chat archives for jdubray/sam-examples

30th
Apr 2017
Slađan Ristić
@sladiri
Apr 30 2017 00:18
Hi, I started an example of SAM in the Cerebral framework. https://github.com/sladiri/sam-cerebral. It does not require a immutable tree, and automatically rerenders components, if a particular part in the state tree changes.
I started with the small Choo framework at first, but the render notifications would result in something what Cerebral already does.
Slađan Ristić
@sladiri
Apr 30 2017 12:20
Cerebral uses Function Tree, which allows for a nice implementation of SAM so far, I think.
  {
      signal: [
        ...ensureSamState,
        guardSamStep,
        {
          true: [warnBlockedAction],
          false: [
            set(state`sam.stepInProgress`, true),
            getProposal(action),
            propose,
            getControlState,
            ensureControlState,
            {
              false: [throwError("Invalid control state.")],
              true: [
                set(state`sam.controlState`, props`controlState`),
                getNextAction,
                when(props`nextAction`),
                {
                  true: [set(state`sam.napInProgress`, true), runNextAction],
                  false: [
                    set(state`sam.napInProgress`, false),
                    set(state`sam.stepInProgress`, false),
                  ],
                },
              ],
            },
          ],
        },
      ],
      catch: new Map([[Error, [logError]]]),
    }