jsaddle-dom-0.10.0.0: src/JSDOM/Generated/RegistrationOptions.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from service-workers (webref). Do not edit.
module JSDOM.Generated.RegistrationOptions
(newRegistrationOptions, setScope, getScope, getScopeUnsafe, getScopeUnchecked, setType, getType, getTypeUnsafe, getTypeUnchecked, setUpdateViaCache, getUpdateViaCache, getUpdateViaCacheUnsafe, getUpdateViaCacheUnchecked, RegistrationOptions(..), gTypeRegistrationOptions)
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://w3c.github.io/ServiceWorker/#dictdef-registrationoptions RegistrationOptions specification>
newRegistrationOptions :: (MonadDOM m) => m RegistrationOptions
newRegistrationOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-scope RegistrationOptions.scope specification>
setScope :: (MonadDOM m, ToJSString val) => RegistrationOptions -> val -> m ()
setScope self val = liftDOM (void (self ^. jss "scope" (toJSVal val)))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-scope RegistrationOptions.scope specification>
getScope :: (MonadDOM m, FromJSString result) => RegistrationOptions -> m (Maybe result)
getScope self = liftDOM (((self ^. js "scope") >>= fromMaybeJSString))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-scope RegistrationOptions.scope specification>
getScopeUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => RegistrationOptions -> m result
getScopeUnsafe self = liftDOM ((((self ^. js "scope") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-scope RegistrationOptions.scope specification>
getScopeUnchecked :: (MonadDOM m, FromJSString result) => RegistrationOptions -> m result
getScopeUnchecked self = liftDOM (((self ^. js "scope") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-type RegistrationOptions.type specification>
setType :: (MonadDOM m) => RegistrationOptions -> WorkerType -> m ()
setType self val = liftDOM (void (self ^. jss "type" (toJSVal val)))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-type RegistrationOptions.type specification>
getType :: (MonadDOM m) => RegistrationOptions -> m (Maybe WorkerType)
getType self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-type RegistrationOptions.type specification>
getTypeUnsafe :: (MonadDOM m, HasCallStack) => RegistrationOptions -> m WorkerType
getTypeUnsafe self = liftDOM ((((self ^. js "type") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-type RegistrationOptions.type specification>
getTypeUnchecked :: (MonadDOM m) => RegistrationOptions -> m WorkerType
getTypeUnchecked self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-updateviacache RegistrationOptions.updateViaCache specification>
setUpdateViaCache :: (MonadDOM m) => RegistrationOptions -> ServiceWorkerUpdateViaCache -> m ()
setUpdateViaCache self val = liftDOM (void (self ^. jss "updateViaCache" (toJSVal val)))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-updateviacache RegistrationOptions.updateViaCache specification>
getUpdateViaCache :: (MonadDOM m) => RegistrationOptions -> m (Maybe ServiceWorkerUpdateViaCache)
getUpdateViaCache self = liftDOM (((self ^. js "updateViaCache") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-updateviacache RegistrationOptions.updateViaCache specification>
getUpdateViaCacheUnsafe :: (MonadDOM m, HasCallStack) => RegistrationOptions -> m ServiceWorkerUpdateViaCache
getUpdateViaCacheUnsafe self = liftDOM ((((self ^. js "updateViaCache") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/ServiceWorker/#dom-registrationoptions-updateviacache RegistrationOptions.updateViaCache specification>
getUpdateViaCacheUnchecked :: (MonadDOM m) => RegistrationOptions -> m ServiceWorkerUpdateViaCache
getUpdateViaCacheUnchecked self = liftDOM (((self ^. js "updateViaCache") >>= fromJSValUnchecked))