module JSDOM.Generated.EventSource
(newEventSource, close, pattern CONNECTING, pattern OPEN,
pattern CLOSED, getUrl, getWithCredentials, getReadyState, open,
message, error, EventSource(..), gTypeEventSource)
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)
import JSDOM.Enums
newEventSource ::
(MonadDOM m, ToJSString url) =>
url -> Maybe EventSourceInit -> m EventSource
newEventSource url eventSourceInitDict
= liftDOM
(EventSource <$>
new (jsg "EventSource") [toJSVal url, toJSVal eventSourceInitDict])
close :: (MonadDOM m) => EventSource -> m ()
close self = liftDOM (void (self ^. jsf "close" ()))
pattern CONNECTING = 0
pattern OPEN = 1
pattern CLOSED = 2
getUrl ::
(MonadDOM m, FromJSString result) => EventSource -> m result
getUrl self = liftDOM ((self ^. js "url") >>= fromJSValUnchecked)
getWithCredentials :: (MonadDOM m) => EventSource -> m Bool
getWithCredentials self
= liftDOM ((self ^. js "withCredentials") >>= valToBool)
getReadyState :: (MonadDOM m) => EventSource -> m Word
getReadyState self
= liftDOM (round <$> ((self ^. js "readyState") >>= valToNumber))
open :: EventName EventSource Event
open = unsafeEventName (toJSString "open")
message :: EventName EventSource MessageEvent
message = unsafeEventName (toJSString "message")
error :: EventName EventSource UIEvent
error = unsafeEventName (toJSString "error")