{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MessageEvent
(newMessageEvent, initMessageEvent, getOrigin, getLastEventId,
getSource, getSourceUnsafe, getSourceUnchecked, getData, getPorts,
MessageEvent(..), gTypeMessageEvent)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
newMessageEvent ::
(MonadDOM m, ToJSString type') =>
type' -> Maybe MessageEventInit -> m MessageEvent
newMessageEvent type' eventInitDict
= liftDOM
(MessageEvent <$>
new (jsg "MessageEvent") [toJSVal type', toJSVal eventInitDict])
initMessageEvent ::
(MonadDOM m, ToJSString type', ToJSVal data', ToJSString originArg,
ToJSString lastEventId, IsMessageEventSource source) =>
MessageEvent ->
type' ->
Bool ->
Bool ->
Maybe data' ->
Maybe originArg ->
Maybe lastEventId -> Maybe source -> [MessagePort] -> m ()
initMessageEvent self type' bubbles cancelable data' originArg
lastEventId source messagePorts
= liftDOM
(void
(self ^. jsf "initMessageEvent"
[toJSVal type', toJSVal bubbles, toJSVal cancelable, toJSVal data',
toJSVal originArg, toJSVal lastEventId, toJSVal source,
toJSVal (array messagePorts)]))
getOrigin ::
(MonadDOM m, FromJSString result) => MessageEvent -> m result
getOrigin self
= liftDOM ((self ^. js "origin") >>= fromJSValUnchecked)
getLastEventId ::
(MonadDOM m, FromJSString result) => MessageEvent -> m result
getLastEventId self
= liftDOM ((self ^. js "lastEventId") >>= fromJSValUnchecked)
getSource :: (MonadDOM m) => MessageEvent -> m (Maybe EventTarget)
getSource self = liftDOM ((self ^. js "source") >>= fromJSVal)
getSourceUnsafe ::
(MonadDOM m, HasCallStack) => MessageEvent -> m EventTarget
getSourceUnsafe self
= liftDOM
(((self ^. js "source") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getSourceUnchecked :: (MonadDOM m) => MessageEvent -> m EventTarget
getSourceUnchecked self
= liftDOM ((self ^. js "source") >>= fromJSValUnchecked)
getData :: (MonadDOM m) => MessageEvent -> m JSVal
getData self = liftDOM ((self ^. js "data") >>= toJSVal)
getPorts :: (MonadDOM m) => MessageEvent -> m [MessagePort]
getPorts self
= liftDOM ((self ^. js "ports") >>= fromJSArrayUnchecked)