jsaddle-dom-0.10.0.0: src/JSDOM/Generated/PushEventInit.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from push-api (webref). Do not edit.
module JSDOM.Generated.PushEventInit
(newPushEventInit, setData, getData, getDataUnsafe, getDataUnchecked, setNotification, getNotification, getNotificationUnsafe, getNotificationUnchecked, PushEventInit(..), gTypePushEventInit)
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/push-api/#dom-pusheventinit PushEventInit specification>
newPushEventInit :: (MonadDOM m) => m PushEventInit
newPushEventInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-data PushEventInit.data specification>
setData :: (MonadDOM m, IsPushMessageDataInit val) => PushEventInit -> Maybe val -> m ()
setData self val = liftDOM (void (self ^. jss "data" (toJSVal val)))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-data PushEventInit.data specification>
getData :: (MonadDOM m) => PushEventInit -> m (Maybe PushMessageDataInit)
getData self = liftDOM (((self ^. js "data") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-data PushEventInit.data specification>
getDataUnsafe :: (MonadDOM m, HasCallStack) => PushEventInit -> m PushMessageDataInit
getDataUnsafe self = liftDOM ((((self ^. js "data") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-data PushEventInit.data specification>
getDataUnchecked :: (MonadDOM m) => PushEventInit -> m PushMessageDataInit
getDataUnchecked self = liftDOM (((self ^. js "data") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-notification PushEventInit.notification specification>
setNotification :: (MonadDOM m) => PushEventInit -> Maybe Notification -> m ()
setNotification self val = liftDOM (void (self ^. jss "notification" (toJSVal val)))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-notification PushEventInit.notification specification>
getNotification :: (MonadDOM m) => PushEventInit -> m (Maybe Notification)
getNotification self = liftDOM (((self ^. js "notification") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-notification PushEventInit.notification specification>
getNotificationUnsafe :: (MonadDOM m, HasCallStack) => PushEventInit -> m Notification
getNotificationUnsafe self = liftDOM ((((self ^. js "notification") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/push-api/#dom-pusheventinit-notification PushEventInit.notification specification>
getNotificationUnchecked :: (MonadDOM m) => PushEventInit -> m Notification
getNotificationUnchecked self = liftDOM (((self ^. js "notification") >>= fromJSValUnchecked))