packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/BroadcastChannel.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from html (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.BroadcastChannel
       (js_newBroadcastChannel, js_close, js_postMessage, js_getName, newBroadcastChannel, close, postMessage, getName, message, messageerror, BroadcastChannel(..), gTypeBroadcastChannel)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(($1) => { return new globalThis[\"BroadcastChannel\"]($1); })"
        js_newBroadcastChannel :: JSString -> IO BroadcastChannel
-- | <https://developer.mozilla.org/docs/Web/API/BroadcastChannel/BroadcastChannel MDN BroadcastChannel. documentation>
newBroadcastChannel :: (MonadDOM m, ToJSString name) => name -> m BroadcastChannel
newBroadcastChannel name = liftDOM ((js_newBroadcastChannel (toJSString name)))

foreign import javascript safe "(($1) => { return $1[\"close\"](); })"
        js_close :: BroadcastChannel -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/BroadcastChannel/close MDN BroadcastChannel.close documentation>
close :: (MonadDOM m) => BroadcastChannel -> m ()
close self = liftDOM (void ((js_close (self))))

foreign import javascript safe "(($1, $2) => { return $1[\"postMessage\"]($2); })"
        js_postMessage :: BroadcastChannel -> JSVal -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/BroadcastChannel/postMessage MDN BroadcastChannel.postMessage documentation>
postMessage :: (MonadDOM m) => BroadcastChannel -> JSVal -> m ()
postMessage self message = liftDOM (void ((js_postMessage (self) (message))))

foreign import javascript unsafe "(($1) => { return $1[\"name\"]; })"
        js_getName :: BroadcastChannel -> IO JSString
-- | <https://developer.mozilla.org/docs/Web/API/BroadcastChannel/name MDN BroadcastChannel.name documentation>
getName :: (MonadDOM m, FromJSString result) => BroadcastChannel -> m result
getName self = liftDOM ((fromJSString <$> (js_getName (self))))

-- | <https://html.spec.whatwg.org/multipage/web-messaging.html#handler-broadcastchannel-onmessage message event>
message :: EventName BroadcastChannel MessageEvent
message = unsafeEventNameAsync (toJSString "message")

-- | <https://html.spec.whatwg.org/multipage/web-messaging.html#handler-broadcastchannel-onmessageerror messageerror event>
messageerror :: EventName BroadcastChannel MessageEvent
messageerror = unsafeEventName (toJSString "messageerror")