jsaddle-dom-0.10.0.0: src/JSDOM/Generated/CommandEvent.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from html (webref). Do not edit.
module JSDOM.Generated.CommandEvent
(newCommandEvent, getSource, getSourceUnsafe, getSourceUnchecked, getCommand, CommandEvent(..), gTypeCommandEvent)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/CommandEvent MDN CommandEvent. documentation>
newCommandEvent :: (MonadDOM m, ToJSString type') => type' -> Maybe CommandEventInit -> m CommandEvent
newCommandEvent type' eventInitDict = liftDOM (((new (jsg "CommandEvent") [toJSVal type', P.maybe (P.return jsUndefined) toJSVal eventInitDict]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSource :: (MonadDOM m) => CommandEvent -> m (Maybe Element)
getSource self = liftDOM (((self ^. js "source") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSourceUnsafe :: (MonadDOM m, HasCallStack) => CommandEvent -> m Element
getSourceUnsafe self = liftDOM ((((self ^. js "source") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSourceUnchecked :: (MonadDOM m) => CommandEvent -> m Element
getSourceUnchecked self = liftDOM (((self ^. js "source") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/command MDN CommandEvent.command documentation>
getCommand :: (MonadDOM m, FromJSString result) => CommandEvent -> m result
getCommand self = liftDOM (((self ^. js "command") >>= fromJSValUnchecked))