miso
Copyright(C) 2016-2025 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.FFI

Description

 
Synopsis

Functions

set :: ToJSVal v => MisoString -> v -> Object -> JSM () Source #

Set property on object

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.

reload :: JSM () Source #

Calls the location.reload() 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>

addEventListener Source #

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)

asyncCallback :: JSM () -> JSM Function Source #

Creates an asynchronous callback function

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

jsonParse :: FromJSON json => JSVal -> JSM json Source #

Parses a MisoString

Image

newtype Image Source #

Constructors

Image JSVal 

Instances

Instances details
ToJSVal Image Source # 
Instance details

Defined in Miso.FFI.Internal

newImage :: MisoString -> JSM Image Source #

Smart constructor for building a Image w/ src attribute.