This module defines types for common DOM events
type Event fields = { "type" :: String, timeStamp :: Number, target :: HTMLElement, currentTarget :: HTMLElement, cancelable :: Boolean, bubbles :: Boolean | fields }
This record synonym captures the properties which appear on every DOM event.
The fields
type parameter allows us to attach different types of additional
properties to represent more specific types of events.
type MouseEvent = (which :: Number, metaKey :: Boolean, altKey :: Boolean, shiftKey :: Boolean, ctrlKey :: Boolean, screenY :: Number, screenX :: Number, clientY :: Number, clientX :: Number, relatedTarget :: HTMLElement, detail :: Number, button :: Number)
Identifies the additional fields which are available on mouse events.
type KeyboardEvent = (which :: Number, metaKey :: Boolean, altKey :: Boolean, shiftKey :: Boolean, ctrlKey :: Boolean, keyCode :: Number, charCode :: Number)
Identifies the additional fields which are available on keyboard events.
type FocusEvent = (relatedTarget :: HTMLElement)
Identifies the additional fields which are available on focus events.
This module defines well-typed wrappers for common DOM events, so that they may be safely embedded in HTML documents.
input :: forall i m a. (Applicative m) => (a -> i) -> a -> EventHandler (m i)
A helper function which can be used to create simple event handlers.
Often we don't need to use EventHandler
or the monad underlying our component, and just need
to generate an input to the signal function.
This function provides an alternative to making two nested calls to pure
:
onClick (input \_ -> Input)
input_ :: forall i m a. (Applicative m) => i -> a -> EventHandler (m i)
A helper function for simple event handlers that provide an input to the signal function, where there is no need to make use of the event value to generate the input.
onclick (input_ Input)
onAbort :: forall i. (Event () -> EventHandler i) -> H.Attr i
onBeforeUnload :: forall i. (Event () -> EventHandler i) -> H.Attr i
onError :: forall i. (Event () -> EventHandler i) -> H.Attr i
onHashChange :: forall i. (Event () -> EventHandler i) -> H.Attr i
onLoad :: forall i. (Event () -> EventHandler i) -> H.Attr i
onPageShow :: forall i. (Event () -> EventHandler i) -> H.Attr i
onPageHide :: forall i. (Event () -> EventHandler i) -> H.Attr i
onResize :: forall i. (Event () -> EventHandler i) -> H.Attr i
onScroll :: forall i. (Event () -> EventHandler i) -> H.Attr i
onUnload :: forall i. (Event () -> EventHandler i) -> H.Attr i
onChange :: forall i. (Event () -> EventHandler i) -> H.Attr i
onInvalid :: forall i. (Event () -> EventHandler i) -> H.Attr i
onReset :: forall i. (Event () -> EventHandler i) -> H.Attr i
onSearch :: forall i. (Event () -> EventHandler i) -> H.Attr i
onSelect :: forall i. (Event () -> EventHandler i) -> H.Attr i
onSubmit :: forall i. (Event () -> EventHandler i) -> H.Attr i
onClick :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onContextMenu :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onDoubleClick :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseDown :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseEnter :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseLeave :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseMove :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseOver :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseOut :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onMouseUp :: forall i. (Event MouseEvent -> EventHandler i) -> H.Attr i
onKeyDown :: forall i. (Event KeyboardEvent -> EventHandler i) -> H.Attr i
onKeyPress :: forall i. (Event KeyboardEvent -> EventHandler i) -> H.Attr i
onKeyUp :: forall i. (Event KeyboardEvent -> EventHandler i) -> H.Attr i
onBlur :: forall i. (Event FocusEvent -> EventHandler i) -> H.Attr i
onFocus :: forall i. (Event FocusEvent -> EventHandler i) -> H.Attr i
onFocusIn :: forall i. (Event FocusEvent -> EventHandler i) -> H.Attr i
onFocusOut :: forall i. (Event FocusEvent -> EventHandler i) -> H.Attr i
This module defines the EventHandler
functor, which can be used
to perform standard operations on HTML events.
newtype EventHandler a
This monad supports the following operations on events:
preventDefault
stopPropagation
stopImmediatePropagation
It can be used as follows:
import Control.Functor (($>))
H.a (E.onclick \_ -> E.preventDefault $> ClickHandler) (H.text "Click here")
preventDefault :: EventHandler Unit
Call the preventDefault
method on the current event
stopPropagation :: EventHandler Unit
Call the stopPropagation
method on the current event
stopImmediatePropagation :: EventHandler Unit
Call the stopImmediatePropagation
method on the current event
instance functorEventHandler :: Functor EventHandler
instance applyEventHandler :: Apply EventHandler
instance applicativeEventHandler :: Applicative EventHandler
instance bindEventHandler :: Bind EventHandler
instance monadEventHandler :: Monad EventHandler
runEventHandler :: forall a fields eff. Event fields -> EventHandler a -> Eff (dom :: DOM | eff) a
This function can be used to update an event and return the wrapped value
This module defines the Event
monad.
newtype Event eff a
= Event (ListT (Aff eff) a)
The Event
monad, which supports the asynchronous generation of events.
This monad is used in the definition of runUI
.
unEvent :: forall eff a. Event eff a -> ListT (Aff eff) a
Unwrap the Event
constructor.
runEvent :: forall eff a. (Error -> Eff eff Unit) -> (a -> Eff eff Unit) -> Event eff a -> Eff eff Unit
Run a computation in the Event
monad by providing a callback function.
The callback function will be invoked zero or more times.
yield :: forall eff a. a -> Event eff a
Yield an event. In practice, the event will be passed to the driver function.
async :: forall eff a. Aff eff a -> Event eff a
Lift an asynchronous computation into the Event
monad.
andThen :: forall eff a. Event eff a -> (a -> Event eff a) -> Event eff a
A combinator which branches based on the supplied function after the first result, and returns to the original stream of events after the secondary stream has been exhausted.
instance semigroupEvent :: Semigroup (Event eff a)
instance monoidEvent :: Monoid (Event eff a)
instance functorEvent :: Functor (Event eff)
instance applyEvent :: Apply (Event eff)
instance applicativeEvent :: Applicative (Event eff)
instance bindEvent :: Bind (Event eff)
instance monadEvent :: Monad (Event eff)
instance monadEffEvent :: MonadEff eff (Event eff)
instance monadAffEvent :: MonadAff eff (Event eff)
instance altEvent :: Alt (Event eff)
instance plusEvent :: Plus (Event eff)
instance alternativeEvent :: Alternative (Event eff)
instance monadPlusEvent :: MonadPlus (Event eff)