ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/IdleRequestOptions.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from requestidlecallback (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.IdleRequestOptions
(js_newIdleRequestOptions, js_setTimeout, js_getTimeout, newIdleRequestOptions, setTimeout, getTimeout, getTimeoutUnsafe, getTimeoutUnchecked, IdleRequestOptions(..), gTypeIdleRequestOptions)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums
foreign import javascript safe "(() => { return ({}); })"
js_newIdleRequestOptions :: IO IdleRequestOptions
-- | <https://w3c.github.io/requestidlecallback/#dom-idlerequestoptions IdleRequestOptions specification>
newIdleRequestOptions :: (MonadDOM m) => m IdleRequestOptions
newIdleRequestOptions = liftDOM ((js_newIdleRequestOptions))
foreign import javascript safe "(($1, $2) => { $1[\"timeout\"] = $2; })"
js_setTimeout :: IdleRequestOptions -> Word -> IO ()
-- | <https://w3c.github.io/requestidlecallback/#dom-idlerequestoptions-timeout IdleRequestOptions.timeout specification>
setTimeout :: (MonadDOM m) => IdleRequestOptions -> Word -> m ()
setTimeout self val = liftDOM (void ((js_setTimeout (self) (val))))
foreign import javascript unsafe "(($1) => { return $1[\"timeout\"]; })"
js_getTimeout :: IdleRequestOptions -> IO JSVal
-- | <https://w3c.github.io/requestidlecallback/#dom-idlerequestoptions-timeout IdleRequestOptions.timeout specification>
getTimeout :: (MonadDOM m) => IdleRequestOptions -> m (Maybe Word)
getTimeout self = liftDOM (((js_getTimeout (self)) >>= fromJSValUnchecked))
-- | <https://w3c.github.io/requestidlecallback/#dom-idlerequestoptions-timeout IdleRequestOptions.timeout specification>
getTimeoutUnsafe :: (MonadDOM m, HasCallStack) => IdleRequestOptions -> m Word
getTimeoutUnsafe self = liftDOM ((((js_getTimeout (self)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://w3c.github.io/requestidlecallback/#dom-idlerequestoptions-timeout IdleRequestOptions.timeout specification>
getTimeoutUnchecked :: (MonadDOM m) => IdleRequestOptions -> m Word
getTimeoutUnchecked self = liftDOM ((pFromJSVal <$> (js_getTimeout (self))))