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

Miso.Native.X.Element.Refresh.Event

Description

Since: 1.13.0.0

Synopsis

Events

onHeaderOffset :: (HeaderOffsetEvent -> action) -> Attribute model action Source #

https://lynxjs.org/api/elements/built-in/refresh.html#bindheaderoffset

Triggered during movement while the <refresh-header> is exposed.

onHeaderOffsetWith :: (HeaderOffsetEvent -> DOMRef -> action) -> Attribute model action Source #

Like onHeaderOffset, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

onHeaderOffsetMain :: (HeaderOffsetEvent -> action) -> EventHandler model action Source #

Like onHeaderOffset, but dispatched on the Lynx main thread (MTS).

Runs imperatively on the MTS (no VDOM diff). Meant to be used with -XStaticPointers.

data Action = Offset HeaderOffsetEvent

view_ [ event (static (onHeaderOffsetMain Offset)) ] [ "some view" ]

onHeaderOffsetMainWith :: (HeaderOffsetEvent -> model -> DOMRef -> action) -> EventHandler model action Source #

Like onHeaderOffsetMain, but the handler also receives read-only access to the model and the target element's DOMRef (for imperative MTS mutation).

data Action = Offset HeaderOffsetEvent Model DOMRef

view_ [ event (static (onHeaderOffsetMainWith Offset)) ] [ "some view" ]

onRefreshStateChangeWith :: (RefreshStateChangeEvent -> DOMRef -> action) -> Attribute model action Source #

Like onRefreshStateChange, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

onRefreshStateChangeMain :: (RefreshStateChangeEvent -> action) -> EventHandler model action Source #

Like onRefreshStateChange, but dispatched on the Lynx main thread (MTS).

Runs imperatively on the MTS (no VDOM diff). Meant to be used with -XStaticPointers.

data Action = StateChanged RefreshStateChangeEvent

view_ [ event (static (onRefreshStateChangeMain StateChanged)) ] [ "some view" ]

onRefreshStateChangeMainWith :: (RefreshStateChangeEvent -> model -> DOMRef -> action) -> EventHandler model action Source #

Like onRefreshStateChangeMain, but the handler also receives read-only access to the model and the target element's DOMRef (for imperative MTS mutation).

data Action = StateChanged RefreshStateChangeEvent Model DOMRef

view_ [ event (static (onRefreshStateChangeMainWith StateChanged)) ] [ "some view" ]

onStartRefresh :: (StartRefreshEvent -> action) -> Attribute model action Source #

https://lynxjs.org/api/elements/built-in/refresh.html#bindstartrefresh

Triggered when the pull threshold is reached or autoStartRefresh is called.

onStartRefreshWith :: (StartRefreshEvent -> DOMRef -> action) -> Attribute model action Source #

Like onStartRefresh, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

onStartRefreshMain :: (StartRefreshEvent -> action) -> EventHandler model action Source #

Like onStartRefresh, but dispatched on the Lynx main thread (MTS).

Runs imperatively on the MTS (no VDOM diff). Meant to be used with -XStaticPointers.

data Action = Started StartRefreshEvent

view_ [ event (static (onStartRefreshMain Started)) ] [ "some view" ]

onStartRefreshMainWith :: (StartRefreshEvent -> model -> DOMRef -> action) -> EventHandler model action Source #

Like onStartRefreshMain, but the handler also receives read-only access to the model and the target element's DOMRef (for imperative MTS mutation).

data Action = Started StartRefreshEvent Model DOMRef

view_ [ event (static (onStartRefreshMainWith Started)) ] [ "some view" ]

Types

data HeaderOffsetEvent Source #

Payload of the bindheaderoffset event.

Constructors

HeaderOffsetEvent 

Fields

data RefreshState Source #

The state of a <refresh-header>, mirrored from Lynx's RefreshState enum.

Since: 1.13.0.0

Instances

Instances details
Show RefreshState Source # 
Instance details

Defined in Miso.Native.X.Element.Refresh.Event

Eq RefreshState Source # 
Instance details

Defined in Miso.Native.X.Element.Refresh.Event

FromJSON RefreshState Source #

Numbering matches Lynx's RefreshState enum (IDLE = 0REFRESHING = 2), the shape the wire actually sends.

Instance details

Defined in Miso.Native.X.Element.Refresh.Event

newtype StartRefreshEvent Source #

Payload of the bindstartrefresh event.

Constructors

StartRefreshEvent 

Fields

  • isManual :: Bool

    Whether the startrefresh event was triggered by a manual drag

Decoders

headerOffsetDecoder :: Decoder HeaderOffsetEvent Source #

Decoder producing a HeaderOffsetEvent from the raw Lynx event payload.

Pass it to on / onMain when writing a handler by hand; the on* helpers in this module already use it.

Since: 1.13.0.0

refreshStateChangeDecoder :: Decoder RefreshStateChangeEvent Source #

Decoder producing a RefreshStateChangeEvent from the raw Lynx event payload.

Pass it to on / onMain when writing a handler by hand; the on* helpers in this module already use it.

Since: 1.13.0.0

startRefreshDecoder :: Decoder StartRefreshEvent Source #

Decoder producing a StartRefreshEvent from the raw Lynx event payload.

Pass it to on / onMain when writing a handler by hand; the on* helpers in this module already use it.

Since: 1.13.0.0

Event Map

refreshEvents :: Events Source #

The Events map for the Lynx refresh element.

Combine with other element maps using <> and pass the result to native, so the delegator listens for these events.

Since: 1.13.0.0