packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/GetNotificationOptions.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from notifications (webref). Do not edit.
module JSDOM.Generated.GetNotificationOptions
       (newGetNotificationOptions, setTag, getTag, getTagUnsafe, getTagUnchecked, GetNotificationOptions(..), gTypeGetNotificationOptions)
       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://notifications.spec.whatwg.org/#dictdef-getnotificationoptions GetNotificationOptions specification>
newGetNotificationOptions :: (MonadDOM m) => m GetNotificationOptions
newGetNotificationOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://notifications.spec.whatwg.org/#dom-getnotificationoptions-tag GetNotificationOptions.tag specification>
setTag :: (MonadDOM m, ToJSString val) => GetNotificationOptions -> val -> m ()
setTag self val = liftDOM (void (self ^. jss "tag" (toJSVal val)))

-- | <https://notifications.spec.whatwg.org/#dom-getnotificationoptions-tag GetNotificationOptions.tag specification>
getTag :: (MonadDOM m, FromJSString result) => GetNotificationOptions -> m (Maybe result)
getTag self = liftDOM (((self ^. js "tag") >>= fromMaybeJSString))

-- | <https://notifications.spec.whatwg.org/#dom-getnotificationoptions-tag GetNotificationOptions.tag specification>
getTagUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => GetNotificationOptions -> m result
getTagUnsafe self = liftDOM ((((self ^. js "tag") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://notifications.spec.whatwg.org/#dom-getnotificationoptions-tag GetNotificationOptions.tag specification>
getTagUnchecked :: (MonadDOM m, FromJSString result) => GetNotificationOptions -> m result
getTagUnchecked self = liftDOM (((self ^. js "tag") >>= fromJSValUnchecked))