Safe Haskell | None |
---|---|
Language | Haskell2010 |
- run :: Int -> JSM () -> IO ()
- syncPoint :: JSM ()
- syncAfter :: JSM a -> JSM a
- waitForAnimationFrame :: JSM Double
- nextAnimationFrame :: (Double -> JSM a) -> JSM a
- jsaddleOr :: ConnectionOptions -> JSM () -> Application -> Application
- data AsyncCommand
- = FreeRef JSValueForSend
- | SetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
- | SetPropertyAtIndex JSObjectForSend Int JSValueForSend
- | StringToValue JSStringForSend JSValueForSend
- | NumberToValue Double JSValueForSend
- | GetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
- | GetPropertyAtIndex JSObjectForSend Int JSValueForSend
- | CallAsFunction JSObjectForSend JSObjectForSend [JSValueForSend] JSValueForSend
- | CallAsConstructor JSObjectForSend [JSValueForSend] JSValueForSend
- | NewEmptyObject JSValueForSend
- | NewCallback JSValueForSend
- | NewArray [JSValueForSend] JSValueForSend
- | EvaluateScript JSStringForSend JSValueForSend
- | SyncWithAnimationFrame JSValueForSend
- data Command
- = DeRefVal JSValueForSend
- | ValueToBool JSValueForSend
- | ValueToNumber JSValueForSend
- | ValueToString JSValueForSend
- | ValueToJSON JSValueForSend
- | IsNull JSValueForSend
- | IsUndefined JSValueForSend
- | StrictEqual JSValueForSend JSValueForSend
- | InstanceOf JSValueForSend JSObjectForSend
- | PropertyNames JSObjectForSend
- | Sync
- data Result
- = DeRefValResult JSValueRef Text
- | ValueToBoolResult Bool
- | ValueToNumberResult Double
- | ValueToStringResult JSStringReceived
- | ValueToJSONResult JSStringReceived
- | IsNullResult Bool
- | IsUndefinedResult Bool
- | StrictEqualResult Bool
- | InstanceOfResult Bool
- | Callback JSValueReceived JSValueReceived [JSValueReceived]
- | PropertyNamesResult [JSStringReceived]
- | ThrowJSValue JSValueReceived
- | ProtocolError Text
- | SyncResult
- sendCommand :: Command -> JSM Result
- sendLazyCommand :: (JSValueForSend -> AsyncCommand) -> JSM JSVal
- sendAsyncCommand :: AsyncCommand -> JSM ()
Running JSM over WebSockets
run :: Int -> JSM () -> IO () Source #
Run the given JSM
action as the main entry point. Either directly
in GHCJS or as a Warp server on the given port on GHC.
waitForAnimationFrame :: JSM Double Source #
On GHCJS this is waitForAnimationFrame
.
On GHC it will delay the execution of the current batch of asynchronous
command when they are sent to JavaScript. It will not delay the Haskell
code execution. The time returned will be based on the Haskell clock
(not the JavaScript clock).
nextAnimationFrame :: (Double -> JSM a) -> JSM a Source #
Tries to executes the given code in the next animation frame callback. Avoid synchronous opperations where possible.
jsaddleOr :: ConnectionOptions -> JSM () -> Application -> Application Source #
Functions used to implement JSaddle over WebSockets
data AsyncCommand Source #
Command sent to a JavaScript context for execution asynchronously
Command sent to a JavaScript context for execution synchronously
Result of a Command
returned from the JavaScript context
sendLazyCommand :: (JSValueForSend -> AsyncCommand) -> JSM JSVal Source #
sendAsyncCommand :: AsyncCommand -> JSM () Source #