miso
Copyright(C) 2016-2025 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Event

Description

 
Synopsis

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