Module

Elmish.Dispatch

#Dispatch

type Dispatch msg = msg -> Effect Unit

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

#handle

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

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.

#(<|)

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

#(<?|)

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

Re-exports from Effect.Uncurried

#EffectFn2

data EffectFn2 :: Type -> Type -> Type -> Type

Instances

#EffectFn1

data EffectFn1 :: Type -> Type -> Type

Instances

#mkEffectFn2

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

#mkEffectFn1

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

Modules