Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Notice = Notice JSRep
- preventDefault :: Notice -> IO ()
- isDefaultPrevented :: Notice -> Bool
- stopPropagation :: Notice -> IO ()
- isPropagationStopped :: Notice -> Bool
- unsafeGetProperty :: PFromJSVal a => JSVal -> JSString -> a
- unsafeGetModifierState :: JSVal -> JSString -> Bool
Documentation
Every event in React is a synthetic event, a cross-browser wrapper around the native event.
which reused from a pool.
So it is dangerous to keep a reference to a Notice
since it may expire and contain
other things without you knowing.
All relevant data from the Notice
must be consumed as soon you get one.
That is, Notice
must only be used in the first part of handleEvent
.
It is not an instance of NFData and so cannot be returned into the second lazy part of handleEvent
preventDefault :: Notice -> IO () Source #
isDefaultPrevented :: Notice -> Bool Source #
stopPropagation :: Notice -> IO () Source #
isPropagationStopped :: Notice -> Bool Source #
unsafeGetProperty :: PFromJSVal a => JSVal -> JSString -> a Source #
Within the strict part of handleEventM
the Notice is effectively immutable.
We want to maintain this lie so that we can lazily parse only the
properties the event handler is interested in.
This will throw if J.JSVal is null, or not convertible to the desired type
so we are assuming that Notice will behave nicely.
unsafeGetModifierState :: JSVal -> JSString -> Bool Source #
See https://www.w3.org/TR/DOM-Level-3-Events-key/#keys-modifier This will throw if J.JSVal is null, but shouldn't happen since we've already check for a valid Notice