Copyright | (C) 2016-2025 David M. Johnson |
---|---|
License | BSD3-style (see the file LICENSE) |
Maintainer | David M. Johnson <code@dmj.io> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Miso.FFI
Description
Synopsis
- set :: ToJSVal v => MisoString -> v -> Object -> JSM ()
- now :: JSM Double
- consoleLog :: MisoString -> JSM ()
- consoleLog' :: JSVal -> JSM ()
- consoleError :: MisoString -> JSM ()
- consoleWarn :: MisoString -> JSM ()
- getElementById :: MisoString -> JSM JSVal
- focus :: MisoString -> JSM ()
- blur :: MisoString -> JSM ()
- alert :: MisoString -> JSM ()
- reload :: JSM ()
- addStyle :: MisoString -> JSM ()
- addStyleSheet :: MisoString -> JSM ()
- addEventListener :: JSVal -> MisoString -> (JSVal -> JSM ()) -> JSM ()
- syncCallback :: JSM () -> JSM Function
- syncCallback1 :: (JSVal -> JSM ()) -> JSM Function
- asyncCallback :: JSM () -> JSM Function
- asyncCallback1 :: (JSVal -> JSM ()) -> JSM Function
- asyncCallback2 :: (JSVal -> JSVal -> JSM ()) -> JSM Function
- flush :: JSM ()
- setDrawingContext :: MisoString -> JSM ()
- jsonStringify :: ToJSON json => json -> JSM MisoString
- jsonParse :: FromJSON json => JSVal -> JSM json
- newtype Image = Image JSVal
- newImage :: MisoString -> JSM Image
Functions
Retrieve high resolution time stamp
See https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
consoleLog :: MisoString -> JSM () Source #
Outputs a message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/log
Console logging of JavaScript strings.
consoleLog' :: JSVal -> JSM () Source #
Console-logging of JSVal
consoleError :: MisoString -> JSM () Source #
Outputs an error message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/error
Console logging of JavaScript strings.
consoleWarn :: MisoString -> JSM () Source #
Outputs a warning message to the web console
See https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
Console logging of JavaScript strings.
getElementById :: MisoString -> JSM JSVal Source #
Returns an Element object representing the element whose id property matches the specified string.
See https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
focus :: MisoString -> JSM () Source #
Fails silently if the element is not found.
Analogous to document.getElementById(id).focus()
.
blur :: MisoString -> JSM () Source #
Fails silently if the element is not found.
Analogous to document.getElementById(id).blur()
alert :: MisoString -> JSM () Source #
Calls the alert()
function.
addStyle :: MisoString -> JSM () Source #
Appends a style_
element containing CSS to head_
addStyle "body { background-color: green; }"
<head><style>body { background-color: green; }</style></head>
addStyleSheet :: MisoString -> JSM () Source #
Appends a StyleSheet link_
element to head_
The link_
tag will contain a URL to a CSS file.
addStyleSheet "https://cdn.jsdelivr.net/npm/todomvc-common@1.0.5/base.min.css"
<head><link href="https://cdn.jsdelivr.net/npm/todomvc-common@1.0.5/base.min.css" ref="stylesheet"></head>
Arguments
:: JSVal | Event target on which we want to register event listener |
-> MisoString | Type of event to listen to (e.g. "click") |
-> (JSVal -> JSM ()) | Callback which will be called when the event occurs, the event will be passed to it as a parameter. |
-> JSM () |
Register an event listener on given target.
syncCallback :: JSM () -> JSM Function Source #
Creates a synchronous callback function (no return value)
asyncCallback1 :: (JSVal -> JSM ()) -> JSM Function Source #
Creates an asynchronous callback function with a single argument
asyncCallback2 :: (JSVal -> JSVal -> JSM ()) -> JSM Function Source #
Creates an asynchronous callback function with a single argument
setDrawingContext :: MisoString -> JSM () Source #
Used to select a drawing context. Users can override the default DOM renderer by implementing their own Context, and exporting it to the global scope. This opens the door to different rendering engines, ala miso-native.
jsonStringify :: ToJSON json => json -> JSM MisoString Source #
Encodes a Haskell object as a JSON string by way of a JavaScript object