{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.ApplicationCache
(update, swapCache, abort, pattern UNCACHED, pattern IDLE,
pattern CHECKING, pattern DOWNLOADING, pattern UPDATEREADY,
pattern OBSOLETE, getStatus, checking, error, noUpdate,
downloading, progress, updateReady, cached, obsolete,
ApplicationCache(..), gTypeApplicationCache)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
update :: (MonadDOM m) => ApplicationCache -> m ()
update self = liftDOM (void (self ^. jsf "update" ()))
swapCache :: (MonadDOM m) => ApplicationCache -> m ()
swapCache self = liftDOM (void (self ^. jsf "swapCache" ()))
abort :: (MonadDOM m) => ApplicationCache -> m ()
abort self = liftDOM (void (self ^. jsf "abort" ()))
pattern UNCACHED = 0
pattern IDLE = 1
pattern CHECKING = 2
pattern DOWNLOADING = 3
pattern UPDATEREADY = 4
pattern OBSOLETE = 5
getStatus :: (MonadDOM m) => ApplicationCache -> m Word
getStatus self
= liftDOM (round <$> ((self ^. js "status") >>= valToNumber))
checking :: EventName ApplicationCache Event
checking = unsafeEventName (toJSString "checking")
error :: EventName ApplicationCache UIEvent
error = unsafeEventNameAsync (toJSString "error")
noUpdate :: EventName ApplicationCache Event
noUpdate = unsafeEventName (toJSString "noupdate")
downloading :: EventName ApplicationCache Event
downloading = unsafeEventName (toJSString "downloading")
progress :: EventName ApplicationCache ProgressEvent
progress = unsafeEventNameAsync (toJSString "progress")
updateReady :: EventName ApplicationCache Event
updateReady = unsafeEventName (toJSString "updateready")
cached :: EventName ApplicationCache Event
cached = unsafeEventName (toJSString "cached")
obsolete :: EventName ApplicationCache Event
obsolete = unsafeEventName (toJSString "obsolete")