miso-1.8.3.0: A tasty Haskell front-end framework

Copyright(C) 2016-2018 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <djohnson.m@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.FFI

Description

 
Synopsis

Documentation

type JSM = IO Source #

The JSM monad keeps track of the JavaScript execution context.

When using GHCJS it is IO.

Given a JSM function and a JSContextRef you can run the function like this...

runJSM jsmFunction javaScriptContext

forkJSM :: JSM () -> JSM () Source #

Run given JSM action asynchronously, in a separate thread.

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

callbackToJSVal :: Function -> JSM JSVal Source #

Convert a Callback into a JSVal

objectToJSVal :: Object -> JSM JSVal Source #

Convert an Object into a JSVal

ghcjsPure :: GHCJSPure a -> JSM a Source #

Used when you want to call a functions that is pure in GHCJS, but lives in the JSM in jsaddle.

syncPoint :: JSM () Source #

Forces execution of pending asyncronous code

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.

windowAddEventListener Source #

Arguments

:: 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 () 

Registers an event listener on window

windowInnerHeight :: JSM Int Source #

Retrieves the height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.

See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight

windowInnerWidth :: JSM Int Source #

Retrieves the width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.

See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth

eventPreventDefault :: JSVal -> JSM () Source #

Prevent default event behavior

eventStopPropagation :: JSVal -> JSM () Source #

Stop propagation of events

consoleLogJSVal :: JSVal -> JSM () Source #

Console-logging

stringify :: ToJSON json => json -> JSM MisoString Source #

Converts a JS object into a JSON string

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

Parses a MisoString

clearBody :: JSM () Source #

Clear the document body. This is particularly useful to avoid creating multiple copies of your app when running in GHCJSi.

objectToJSON Source #

Arguments

:: JSVal

decodeAt :: [JSString]

-> JSVal

object with impure references to the DOM

-> JSM JSVal 

Convert a JavaScript object to JSON

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

Set property on object

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

diff' Source #

Arguments

:: Object

current object

-> Object

new object

-> JSVal

parent node

-> JSVal

document

-> JSM () 

Diff two virtual DOMs

integralToJSString :: Integral a => a -> MisoString Source #

Helper function for converting Integral types to JavaScript strings

realFloatToJSString :: RealFloat a => a -> MisoString Source #

Helper function for converting RealFloat types to JavaScript strings

jsStringToDouble :: MisoString -> Double Source #

Helper function for converting RealFloat types to JavaScript strings

delegateEvent :: JSVal -> JSVal -> JSM JSVal -> JSM () Source #

Initialize event delegation from a mount point.

copyDOMIntoVTree :: Bool -> JSVal -> JSVal -> JSM () Source #

Copies DOM pointers into virtual dom entry point into isomorphic javascript

swapCallbacks :: JSM () Source #

Pins down the current callbacks for clearing later

releaseCallbacks :: JSM () Source #

Releases callbacks registered by the virtual DOM.

registerCallback :: JSVal -> JSM () Source #

Mock for callback registration

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()

scrollIntoView :: MisoString -> JSM () Source #

Calls document.getElementById(id).scrollIntoView()

alert :: MisoString -> JSM () Source #

Calls the alert() function.