Module

Elmish.Dispatch

Package
purescript-elmish
Repository
collegevine/purescript-elmish

#Dispatch Source

type Dispatch msg = msg -> Effect Unit

A function that a view can use to report messages originating from JS/DOM.

#handle Source

handle :: forall arg msg. Dispatch msg -> (arg -> msg) -> EffectFn1 arg Unit

A convenience function to make construction of event handlers with arguments (i.e. EffectFn1) a bit shorter. The function takes a Dispatch and a mapping from the event argument to a message which the given Dispatch accepts, and it's also available in operator form.

The following example demonstrates expected usage of both handle (in its operator form <|) and handleMaybe (in its operator form <?|):

textarea
  { value: state.text
  , onChange: dispatch <?| \e -> TextChanged <$> eventTargetValue e
  , onMouseDown: dispatch <| \_ -> TextareaClicked
  }

  where
    eventTargetValue = readForeign >=> lookup "target" >=> readForeign >=> lookup "value"

#handleMaybe Source

handleMaybe :: forall arg msg. Dispatch msg -> (arg -> Maybe msg) -> EffectFn1 arg Unit

Same as handle, but dispatches a message optionally. See comments on handle for an example.

#(<|) Source

Operator alias for Elmish.Dispatch.handle (right-associative / precedence 9)

#(<?|) Source

Operator alias for Elmish.Dispatch.handleMaybe (right-associative / precedence 9)

Re-exports from Effect.Uncurried

#EffectFn2 Source

data EffectFn2 t0 t1 t2

Instances

#EffectFn1 Source

data EffectFn1 t0 t1

Instances

#mkEffectFn2 Source

mkEffectFn2 :: forall a b r. (a -> b -> Effect r) -> EffectFn2 a b r

#mkEffectFn1 Source

mkEffectFn1 :: forall a r. (a -> Effect r) -> EffectFn1 a r