| 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
Functions for specifying component lifecycle events and event handlers in View.
Synopsis
- on :: MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action
- onCapture :: MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action
- onWithOptions :: Phase -> Options -> MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action
- data Phase
- onMounted :: action -> Attribute action
- onMountedWith :: (DOMRef -> action) -> Attribute action
- onBeforeMounted :: action -> Attribute action
- onUnmounted :: action -> Attribute action
- onUnmountedWith :: (DOMRef -> action) -> Attribute action
- onBeforeUnmounted :: action -> Attribute action
- onBeforeUnmountedWith :: (DOMRef -> action) -> Attribute action
- onCreated :: action -> Attribute action
- onCreatedWith :: (DOMRef -> action) -> Attribute action
- onBeforeCreated :: action -> Attribute action
- onDestroyed :: action -> Attribute action
- onBeforeDestroyed :: action -> Attribute action
- onBeforeDestroyedWith :: (DOMRef -> 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_ "+" ]
This is used to define events that are triggered during the browser bubble phase.
onCapture :: MisoString -> Decoder r -> (r -> DOMRef -> action) -> Attribute action Source #
Convenience wrapper for onWithOptions (True :: Capture).
let clickHandler = onCapture "click" emptyDecoder $ \() -> Action in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]
This is used to define events that are triggered during the browser capture phase.
onWithOptions :: Phase -> 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_ "+" ]
Phase during which event listener is invoked.
Since: 1.9.0.0
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 :: (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.
Passes the DOMRef to the action.
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 :: (DOMRef -> action) -> Attribute action Source #
onUnmountedWith action is an event that gets called after the DOM element
is removed from the DOM. Passes the DOMRef to the action.
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
onBeforeUnmountedWith :: (DOMRef -> action) -> Attribute action Source #
onBeforeUnmountedWith is an event that gets called before the Component
unmounts and 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 :: (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.
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.
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.
Since: 1.9.0.0
onBeforeDestroyedWith :: (DOMRef -> action) -> Attribute action Source #
Like onBeforeDestroyed but passes along the DOMRef
Since: 1.9.0.0
Exports
module Miso.Event.Decoder
module Miso.Event.Types