-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Native.X.Element.Webview.Event
-- Copyright   :  (C) 2016-2026 David M. Johnson
-- License     :  BSD3-style (see the file LICENSE)
-- Maintainer  :  David M. Johnson <code@dmj.io>
-- Stability   :  experimental
-- Portability :  non-portable
----------------------------------------------------------------------------
module Miso.Native.X.Element.Webview.Event
  ( -- *** Events
    onError
  , onErrorWith
  , onErrorMain
  , onErrorMainWith
  , onLoad
  , onLoadWith
  , onLoadMain
  , onLoadMainWith
  , onLocationChange
  , onLocationChangeWith
  , onLocationChangeMain
  , onLocationChangeMainWith
  , onMessage
  , onMessageWith
  , onMessageMain
  , onMessageMainWith
  , onOpenWindow
  , onOpenWindowWith
  , onOpenWindowMain
  , onOpenWindowMainWith
    -- *** Types
  , WebviewErrorEvent (..)
    -- *** Decoders
  , webviewErrorDecoder
  , urlDecoder
  , messageDecoder
    -- *** Event Map
  , webviewEvents
  ) where
-----------------------------------------------------------------------------
import qualified Data.Map as M
-----------------------------------------------------------------------------
import           Miso.Event
import           Miso.JSON
import           Miso.String (MisoString)
import           Miso.Types (Attribute, EventHandler, DOMRef)
-----------------------------------------------------------------------------
webviewEvents :: Events
webviewEvents :: Events
webviewEvents
  = [(MisoString, Phase)] -> Events
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
  [ (MisoString
"error", Phase
BUBBLE)
  , (MisoString
"load", Phase
BUBBLE)
  , (MisoString
"locationchange", Phase
BUBBLE)
  , (MisoString
"message", Phase
BUBBLE)
  , (MisoString
"openwindow", Phase
BUBBLE)
  ]
-----------------------------------------------------------------------------
-- | Payload of the @binderror@ event.
data WebviewErrorEvent
  = WebviewErrorEvent
  { WebviewErrorEvent -> Int
errorCode :: Int
    -- ^ The error code
  , WebviewErrorEvent -> MisoString
errorMsg :: MisoString
    -- ^ The error message
  } deriving (Int -> WebviewErrorEvent -> ShowS
[WebviewErrorEvent] -> ShowS
WebviewErrorEvent -> String
(Int -> WebviewErrorEvent -> ShowS)
-> (WebviewErrorEvent -> String)
-> ([WebviewErrorEvent] -> ShowS)
-> Show WebviewErrorEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WebviewErrorEvent -> ShowS
showsPrec :: Int -> WebviewErrorEvent -> ShowS
$cshow :: WebviewErrorEvent -> String
show :: WebviewErrorEvent -> String
$cshowList :: [WebviewErrorEvent] -> ShowS
showList :: [WebviewErrorEvent] -> ShowS
Show, WebviewErrorEvent -> WebviewErrorEvent -> Bool
(WebviewErrorEvent -> WebviewErrorEvent -> Bool)
-> (WebviewErrorEvent -> WebviewErrorEvent -> Bool)
-> Eq WebviewErrorEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WebviewErrorEvent -> WebviewErrorEvent -> Bool
== :: WebviewErrorEvent -> WebviewErrorEvent -> Bool
$c/= :: WebviewErrorEvent -> WebviewErrorEvent -> Bool
/= :: WebviewErrorEvent -> WebviewErrorEvent -> Bool
Eq)
-----------------------------------------------------------------------------
webviewErrorDecoder :: Decoder WebviewErrorEvent
webviewErrorDecoder :: Decoder WebviewErrorEvent
webviewErrorDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser WebviewErrorEvent) -> Decoder WebviewErrorEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser WebviewErrorEvent
details
  where
    details :: Value -> Parser WebviewErrorEvent
details = MisoString
-> (Object -> Parser WebviewErrorEvent)
-> Value
-> Parser WebviewErrorEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser WebviewErrorEvent)
 -> Value -> Parser WebviewErrorEvent)
-> (Object -> Parser WebviewErrorEvent)
-> Value
-> Parser WebviewErrorEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
      Int -> MisoString -> WebviewErrorEvent
WebviewErrorEvent
        (Int -> MisoString -> WebviewErrorEvent)
-> Parser Int -> Parser (MisoString -> WebviewErrorEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser Int
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"errorCode"
        Parser (MisoString -> WebviewErrorEvent)
-> Parser MisoString -> Parser WebviewErrorEvent
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"errorMsg"
-----------------------------------------------------------------------------
-- | Decodes the @url@ field of @bindlocationchange@ and @bindopenwindow@.
urlDecoder :: Decoder MisoString
urlDecoder :: Decoder MisoString
urlDecoder = [MisoString
"detail"] [MisoString] -> (Value -> Parser MisoString) -> Decoder MisoString
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser MisoString
details
  where
    details :: Value -> Parser MisoString
details = MisoString
-> (Object -> Parser MisoString) -> Value -> Parser MisoString
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser MisoString) -> Value -> Parser MisoString)
-> (Object -> Parser MisoString) -> Value -> Parser MisoString
forall a b. (a -> b) -> a -> b
$ \Object
o -> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"url"
-----------------------------------------------------------------------------
-- | Decodes the @msg@ field of @bindmessage@.
messageDecoder :: Decoder MisoString
messageDecoder :: Decoder MisoString
messageDecoder = [MisoString
"detail"] [MisoString] -> (Value -> Parser MisoString) -> Decoder MisoString
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser MisoString
details
  where
    details :: Value -> Parser MisoString
details = MisoString
-> (Object -> Parser MisoString) -> Value -> Parser MisoString
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser MisoString) -> Value -> Parser MisoString)
-> (Object -> Parser MisoString) -> Value -> Parser MisoString
forall a b. (a -> b) -> a -> b
$ \Object
o -> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"msg"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/webview.html#binderror
--
-- Triggered on a webview error.
--
onError :: (WebviewErrorEvent -> action) -> Attribute model action
onError :: forall action model.
(WebviewErrorEvent -> action) -> Attribute model action
onError WebviewErrorEvent -> action
action = MisoString
-> Decoder WebviewErrorEvent
-> (WebviewErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"error" Decoder WebviewErrorEvent
webviewErrorDecoder (\WebviewErrorEvent
e model
_ DOMRef
_ -> WebviewErrorEvent -> action
action WebviewErrorEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onError', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Errored WebviewErrorEvent
--
-- view_ [ event (static (onErrorMain Errored)) ] [ "some view" ]
-- @
--
onErrorMain :: (WebviewErrorEvent -> action) -> EventHandler model action
onErrorMain :: forall action model.
(WebviewErrorEvent -> action) -> EventHandler model action
onErrorMain WebviewErrorEvent -> action
action = MisoString
-> Decoder WebviewErrorEvent
-> (WebviewErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"error" Decoder WebviewErrorEvent
webviewErrorDecoder (\WebviewErrorEvent
e model
_ DOMRef
_ -> WebviewErrorEvent -> action
action WebviewErrorEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onErrorMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Errored WebviewErrorEvent Model DOMRef
--
-- view_ [ event (static (onErrorMainWith Errored)) ] [ "some view" ]
-- @
--
onErrorMainWith :: (WebviewErrorEvent -> model -> DOMRef -> action) -> EventHandler model action
onErrorMainWith :: forall model action.
(WebviewErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
onErrorMainWith WebviewErrorEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder WebviewErrorEvent
-> (WebviewErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"error" Decoder WebviewErrorEvent
webviewErrorDecoder WebviewErrorEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/webview.html#bindload
--
-- Triggered when the webview loads successfully.
--
onLoad :: action -> Attribute model action
onLoad :: forall action model. action -> Attribute model action
onLoad action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"load" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onLoad', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Loaded
--
-- view_ [ event (static (onLoadMain Loaded)) ] [ "some view" ]
-- @
--
onLoadMain :: action -> EventHandler model action
onLoadMain :: forall action model. action -> EventHandler model action
onLoadMain action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"load" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onLoadMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Loaded Model DOMRef
--
-- view_ [ event (static (onLoadMainWith Loaded)) ] [ "some view" ]
-- @
--
onLoadMainWith :: (model -> DOMRef -> action) -> EventHandler model action
onLoadMainWith :: forall model action.
(model -> DOMRef -> action) -> EventHandler model action
onLoadMainWith model -> DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"load" Decoder ()
emptyDecoder (\() model
m DOMRef
ref -> model -> DOMRef -> action
action model
m DOMRef
ref)
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/webview.html#bindlocationchange
--
-- *Desktop, Lynx 3.5+*. Triggered when the location changes.
--
onLocationChange :: (MisoString -> action) -> Attribute model action
onLocationChange :: forall action model.
(MisoString -> action) -> Attribute model action
onLocationChange MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"locationchange" Decoder MisoString
urlDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onLocationChange', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = LocationChanged MisoString
--
-- view_ [ event (static (onLocationChangeMain LocationChanged)) ] [ "some view" ]
-- @
--
onLocationChangeMain :: (MisoString -> action) -> EventHandler model action
onLocationChangeMain :: forall action model.
(MisoString -> action) -> EventHandler model action
onLocationChangeMain MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"locationchange" Decoder MisoString
urlDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onLocationChangeMain', but the handler also receives read-only access
-- to the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = LocationChanged MisoString Model DOMRef
--
-- view_ [ event (static (onLocationChangeMainWith LocationChanged)) ] [ "some view" ]
-- @
--
onLocationChangeMainWith :: (MisoString -> model -> DOMRef -> action) -> EventHandler model action
onLocationChangeMainWith :: forall model action.
(MisoString -> model -> DOMRef -> action)
-> EventHandler model action
onLocationChangeMainWith MisoString -> model -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"locationchange" Decoder MisoString
urlDecoder MisoString -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/webview.html#bindmessage
--
-- Triggered when a message is posted from JavaScript.
--
onMessage :: (MisoString -> action) -> Attribute model action
onMessage :: forall action model.
(MisoString -> action) -> Attribute model action
onMessage MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"message" Decoder MisoString
messageDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onMessage', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Message MisoString
--
-- view_ [ event (static (onMessageMain Message)) ] [ "some view" ]
-- @
--
onMessageMain :: (MisoString -> action) -> EventHandler model action
onMessageMain :: forall action model.
(MisoString -> action) -> EventHandler model action
onMessageMain MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"message" Decoder MisoString
messageDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onMessageMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Message MisoString Model DOMRef
--
-- view_ [ event (static (onMessageMainWith Message)) ] [ "some view" ]
-- @
--
onMessageMainWith :: (MisoString -> model -> DOMRef -> action) -> EventHandler model action
onMessageMainWith :: forall model action.
(MisoString -> model -> DOMRef -> action)
-> EventHandler model action
onMessageMainWith MisoString -> model -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"message" Decoder MisoString
messageDecoder MisoString -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/webview.html#bindopenwindow
--
-- *Desktop, Lynx 3.5+*. Triggered on an open-window event.
--
onOpenWindow :: (MisoString -> action) -> Attribute model action
onOpenWindow :: forall action model.
(MisoString -> action) -> Attribute model action
onOpenWindow MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"openwindow" Decoder MisoString
urlDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onOpenWindow', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = OpenWindow MisoString
--
-- view_ [ event (static (onOpenWindowMain OpenWindow)) ] [ "some view" ]
-- @
--
onOpenWindowMain :: (MisoString -> action) -> EventHandler model action
onOpenWindowMain :: forall action model.
(MisoString -> action) -> EventHandler model action
onOpenWindowMain MisoString -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"openwindow" Decoder MisoString
urlDecoder (\MisoString
e model
_ DOMRef
_ -> MisoString -> action
action MisoString
e)
-----------------------------------------------------------------------------
-- | Like 'onOpenWindowMain', but the handler also receives read-only access to
-- the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = OpenWindow MisoString Model DOMRef
--
-- view_ [ event (static (onOpenWindowMainWith OpenWindow)) ] [ "some view" ]
-- @
--
onOpenWindowMainWith :: (MisoString -> model -> DOMRef -> action) -> EventHandler model action
onOpenWindowMainWith :: forall model action.
(MisoString -> model -> DOMRef -> action)
-> EventHandler model action
onOpenWindowMainWith MisoString -> model -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"openwindow" Decoder MisoString
urlDecoder MisoString -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
-- | Like 'onError', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onErrorWith :: (WebviewErrorEvent -> DOMRef -> action) -> Attribute model action
onErrorWith :: forall action model.
(WebviewErrorEvent -> DOMRef -> action) -> Attribute model action
onErrorWith WebviewErrorEvent -> DOMRef -> action
action = MisoString
-> Decoder WebviewErrorEvent
-> (WebviewErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"error" Decoder WebviewErrorEvent
webviewErrorDecoder ((WebviewErrorEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (WebviewErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \WebviewErrorEvent
v model
_ DOMRef
domRef -> WebviewErrorEvent -> DOMRef -> action
action WebviewErrorEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onLoad', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onLoadWith :: (DOMRef -> action) -> Attribute model action
onLoadWith :: forall action model. (DOMRef -> action) -> Attribute model action
onLoadWith DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"load" Decoder ()
emptyDecoder (\() model
_ DOMRef
ref -> DOMRef -> action
action DOMRef
ref)
-----------------------------------------------------------------------------
-- | Like 'onLocationChange', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onLocationChangeWith :: (MisoString -> DOMRef -> action) -> Attribute model action
onLocationChangeWith :: forall action model.
(MisoString -> DOMRef -> action) -> Attribute model action
onLocationChangeWith MisoString -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"locationchange" Decoder MisoString
urlDecoder ((MisoString -> model -> DOMRef -> action)
 -> Attribute model action)
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \MisoString
v model
_ DOMRef
domRef -> MisoString -> DOMRef -> action
action MisoString
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onMessage', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onMessageWith :: (MisoString -> DOMRef -> action) -> Attribute model action
onMessageWith :: forall action model.
(MisoString -> DOMRef -> action) -> Attribute model action
onMessageWith MisoString -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"message" Decoder MisoString
messageDecoder ((MisoString -> model -> DOMRef -> action)
 -> Attribute model action)
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \MisoString
v model
_ DOMRef
domRef -> MisoString -> DOMRef -> action
action MisoString
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onOpenWindow', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onOpenWindowWith :: (MisoString -> DOMRef -> action) -> Attribute model action
onOpenWindowWith :: forall action model.
(MisoString -> DOMRef -> action) -> Attribute model action
onOpenWindowWith MisoString -> DOMRef -> action
action = MisoString
-> Decoder MisoString
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"openwindow" Decoder MisoString
urlDecoder ((MisoString -> model -> DOMRef -> action)
 -> Attribute model action)
-> (MisoString -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \MisoString
v model
_ DOMRef
domRef -> MisoString -> DOMRef -> action
action MisoString
v DOMRef
domRef
-----------------------------------------------------------------------------