Example #1
0
  (model:Model, action:Action):[Model, Effects<Action>] =>
  ( action.type === "Press"
  ? [ merge(model, {isChecked: !model.isChecked})
    , ( model.isChecked
      ? Effects.perform(Task.succeed(Uncheck))
      : Effects.perform(Task.succeed(Check))
      )
    ]

  : action.type === "Check"
  ? [ merge(model, {isChecked: true })
    , Effects.none
    ]
  : action.type === "Uncheck"
  ? [ merge(model, {isChecked: false })
    , Effects.none
    ]
  : action.type === "Button"
  ? mapFX(ButtonAction, Button.update(model, action.button))
  : action.type === "Target"
  ? mapFX(TargetAction, Target.update(model, action.target))
  : action.type === "Focusable"
  ? mapFX(FocusableAction, Focusable.update(model, action.focusable))
  : Unknown.update(model, action)
  );
Example #2
0
  (model/*:Model*/, action/*:Action*/)/*:[Model, Effects<Action>]*/ =>
  ( action.type === "Press"
  ? [ merge(model, {isChecked: !model.isChecked})
    , ( model.isChecked
      ? Effects.perform(Task.succeed(Uncheck))
      : Effects.perform(Task.succeed(Check))
      )
    ]

  : action.type === "Check"
  ? [ merge(model, {isChecked: true })
    , Effects.none
    ]
  : action.type === "Uncheck"
  ? [ merge(model, {isChecked: false })
    , Effects.none
    ]
  : action.type === "Button"
  ? updateButton(model, action.action)
  : action.type === "Target"
  ? updateTarget(model, action.action)
  : action.type === "Focusable"
  ? updateFocusable(model, action.action)
  : Unknown.update(model, action)
  );
Example #3
0
 (model:Model):[Model, Effects<Action>] =>
 ( model.isChecked
 ? [ new Model(false, model.button)
   , Effects.perform(Task.succeed(Uncheck))
   ]
 : [ new Model(true, model.button)
   , Effects.perform(Task.succeed(Check))
   ]
 )
Example #4
0
 .capture(reason => Task.succeed(error(reason)))
Example #5
0
 Task.io(deliver => Task.succeed(document.hasFocus()));