Copyright | (C) 2016-2025 David M. Johnson |
---|---|
License | BSD3-style (see the file LICENSE) |
Maintainer | David M. Johnson <code@dmj.io> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Miso.Event
Description
Synopsis
- on :: MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action
- onWithOptions :: Options -> MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action
- onMounted :: action -> Attribute action
- onMountedWith :: (ComponentId -> action) -> Attribute action
- onMountedWith_ :: (DOMRef -> action) -> Attribute action
- onBeforeMounted :: action -> Attribute action
- onUnmounted :: action -> Attribute action
- onUnmountedWith :: (ComponentId -> action) -> Attribute action
- onUnmountedWith_ :: (DOMRef -> action) -> Attribute action
- onBeforeUnmounted :: action -> Attribute action
- onCreated :: action -> Attribute action
- onCreatedWith :: (ComponentId -> action) -> Attribute action
- onCreatedWith_ :: (DOMRef -> action) -> Attribute action
- onBeforeCreated :: action -> Attribute action
- onDestroyed :: action -> Attribute action
- onBeforeDestroyed :: action -> Attribute action
- module Miso.Event.Decoder
- module Miso.Event.Types
Smart constructors
on :: MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action Source #
Convenience wrapper for onWithOptions defaultOptions
.
let clickHandler = on "click" emptyDecoder $ \() -> Action in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]
onWithOptions :: Options -> MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action Source #
onWithOptions opts eventName decoder toAction
is an attribute
that will set the event handler of the associated DOM node to a function that
decodes its argument using decoder
, converts it to an action
using toAction
and then feeds that action back to the update
function.
opts
can be used to disable further event propagation.
let clickHandler = onWithOptions defaultOptions "click" emptyDecoder $ \() -> Action in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]
Lifecycle events
onMounted :: action -> Attribute action Source #
onMounted action
is an event that gets called after the actual DOM
element is created.
Since: 1.9.0.0
onMountedWith :: (ComponentId -> action) -> Attribute action Source #
onMountedWith action
is an event that gets called after the actual DOM
element is created. It returns the componentId from the component.
Returning componentId is useful when creating Component
dynamically.
Use this or onMounted
, but not both in the same [Attribute action]
list.
Since: 1.9.0.0
onMountedWith_ :: (DOMRef -> action) -> Attribute action Source #
onMountedWith action
is an event that gets called after the actual DOM
element is created. It returns the componentId from the component.
Returning componentId is useful when creating Component
dynamically.
Use this or onMounted
, but not both in the same [Attribute action]
list.
Since: 1.9.0.0
onBeforeMounted :: action -> Attribute action Source #
onBeforeMounted action
is an event that gets called before the actual DOM
element is created.
Since: 1.9.0.0
onUnmounted :: action -> Attribute action Source #
onUnmounted action
is an event that gets called after the DOM element
is removed from the DOM.
Since: 1.9.0.0
onUnmountedWith :: (ComponentId -> action) -> Attribute action Source #
onUnmounted action
is an event that gets called after the DOM element
is removed from the DOM. It returns the componentId after the unmount call.
Use this or onUnmounted
, but not both in the same [Attribute action]
list.
Since: 1.9.0.0
onUnmountedWith_ :: (DOMRef -> action) -> Attribute action Source #
onUnmounted action
is an event that gets called after the DOM element
is removed from the DOM. It returns the componentId after the unmount call.
Use this or onUnmounted
, but not both in the same [Attribute action]
list.
Since: 1.9.0.0
onBeforeUnmounted :: action -> Attribute action Source #
onBeforeUnmounted action
is an event that gets called before the DOM element
is removed from the DOM.
Since: 1.9.0.0
onCreated :: action -> Attribute action Source #
onCreated action
is an event that gets called after the actual DOM
element is created.
Since: 1.9.0.0
onCreatedWith :: (ComponentId -> action) -> Attribute action Source #
Like onCreated action
but passes along the ComponentId
Since: 1.9.0.0
onCreatedWith_ :: (DOMRef -> action) -> Attribute action Source #
Like onCreated action
but passes along the DOMRef
Since: 1.9.0.0
onBeforeCreated :: action -> Attribute action Source #
onBeforeCreated action
is an event that gets called before the DOM element
is created on the DOM. The action
is given the DOM element that was
removed from the DOM tree.
Since: 1.9.0.0
onDestroyed :: action -> Attribute action Source #
onDestroyed action
is an event that gets called after the DOM element
is removed from the DOM. The action
is given the DOM element that was
removed from the DOM tree.
Since: 1.9.0.0
onBeforeDestroyed :: action -> Attribute action Source #
onBeforeDestroyed action
is an event that gets called before the DOM element
is removed from the DOM. The action
is given the DOM element that was
removed from the DOM tree.
Since: 1.9.0.0
Exports
module Miso.Event.Decoder
module Miso.Event.Types