jsaddle-dom-0.10.0.0: src/JSDOM/Generated/NotificationEventInit.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.NotificationEventInit
(newNotificationEventInit, setNotification, getNotification, setAction, getAction, getActionUnsafe, getActionUnchecked, NotificationEventInit(..), gTypeNotificationEventInit)
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-notificationeventinit NotificationEventInit specification>
newNotificationEventInit :: (MonadDOM m) => Notification -> m NotificationEventInit
newNotificationEventInit notification = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "notification" (toJSVal notification)) P.>> P.return o)) >>= fromJSValUnchecked))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-notification NotificationEventInit.notification specification>
setNotification :: (MonadDOM m) => NotificationEventInit -> Notification -> m ()
setNotification self val = liftDOM (void (self ^. jss "notification" (toJSVal val)))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-notification NotificationEventInit.notification specification>
getNotification :: (MonadDOM m) => NotificationEventInit -> m Notification
getNotification self = liftDOM (((self ^. js "notification") >>= fromJSValUnchecked))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-action NotificationEventInit.action specification>
setAction :: (MonadDOM m, ToJSString val) => NotificationEventInit -> val -> m ()
setAction self val = liftDOM (void (self ^. jss "action" (toJSVal val)))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-action NotificationEventInit.action specification>
getAction :: (MonadDOM m, FromJSString result) => NotificationEventInit -> m (Maybe result)
getAction self = liftDOM (((self ^. js "action") >>= fromMaybeJSString))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-action NotificationEventInit.action specification>
getActionUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => NotificationEventInit -> m result
getActionUnsafe self = liftDOM ((((self ^. js "action") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://notifications.spec.whatwg.org/#dom-notificationeventinit-action NotificationEventInit.action specification>
getActionUnchecked :: (MonadDOM m, FromJSString result) => NotificationEventInit -> m result
getActionUnchecked self = liftDOM (((self ^. js "action") >>= fromJSValUnchecked))