jsaddle-dom-0.10.0.0: src/JSDOM/Generated/EventSourceInit.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.EventSourceInit
(newEventSourceInit, setWithCredentials, getWithCredentials, getWithCredentialsUnsafe, getWithCredentialsUnchecked, EventSourceInit(..), gTypeEventSourceInit)
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://html.spec.whatwg.org/multipage/server-sent-events.html#eventsourceinit EventSourceInit specification>
newEventSourceInit :: (MonadDOM m) => m EventSourceInit
newEventSourceInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsourceinit-withcredentials EventSourceInit.withCredentials specification>
setWithCredentials :: (MonadDOM m) => EventSourceInit -> Bool -> m ()
setWithCredentials self val = liftDOM (void (self ^. jss "withCredentials" (toJSVal val)))
-- | <https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsourceinit-withcredentials EventSourceInit.withCredentials specification>
getWithCredentials :: (MonadDOM m) => EventSourceInit -> m (Maybe Bool)
getWithCredentials self = liftDOM (((self ^. js "withCredentials") >>= fromJSValUnchecked))
-- | <https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsourceinit-withcredentials EventSourceInit.withCredentials specification>
getWithCredentialsUnsafe :: (MonadDOM m, HasCallStack) => EventSourceInit -> m Bool
getWithCredentialsUnsafe self = liftDOM ((((self ^. js "withCredentials") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsourceinit-withcredentials EventSourceInit.withCredentials specification>
getWithCredentialsUnchecked :: (MonadDOM m) => EventSourceInit -> m Bool
getWithCredentialsUnchecked self = liftDOM (((self ^. js "withCredentials") >>= valToBool))