jsaddle-dom-0.10.0.0: src/JSDOM/Generated/MIDIConnectionEvent.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webmidi (webref). Do not edit.
module JSDOM.Generated.MIDIConnectionEvent
(newMIDIConnectionEvent, getPort, getPortUnsafe, getPortUnchecked, MIDIConnectionEvent(..), gTypeMIDIConnectionEvent)
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/MIDIConnectionEvent/MIDIConnectionEvent MDN MIDIConnectionEvent. documentation>
newMIDIConnectionEvent :: (MonadDOM m, ToJSString type') => type' -> Maybe MIDIConnectionEventInit -> m MIDIConnectionEvent
newMIDIConnectionEvent type' eventInitDict = liftDOM (((new (jsg "MIDIConnectionEvent") [toJSVal type', P.maybe (P.return jsUndefined) toJSVal eventInitDict]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent/port MDN MIDIConnectionEvent.port documentation>
getPort :: (MonadDOM m) => MIDIConnectionEvent -> m (Maybe MIDIPort)
getPort self = liftDOM (((self ^. js "port") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent/port MDN MIDIConnectionEvent.port documentation>
getPortUnsafe :: (MonadDOM m, HasCallStack) => MIDIConnectionEvent -> m MIDIPort
getPortUnsafe self = liftDOM ((((self ^. js "port") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent/port MDN MIDIConnectionEvent.port documentation>
getPortUnchecked :: (MonadDOM m) => MIDIConnectionEvent -> m MIDIPort
getPortUnchecked self = liftDOM (((self ^. js "port") >>= fromJSValUnchecked))