Module
Elmish.Dispatch
- Package
- purescript-elmish
- Repository
- collegevine/purescript-elmish
#handle Source
handle :: forall arg msg. Dispatch msg -> (arg -> msg) -> EffectFn1 arg UnitA 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 UnitSame as handle, but dispatches a message optionally. See comments on
handle for an example.
Re-exports from Effect.Uncurried
#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