Module

Hareactive.DOM

Package
purescript-hareactive
Repository
funkia/purescript-hareactive

This module contains functions for interacting with DOM.

#streamFromEvent Source

streamFromEvent :: EventType -> EventTarget -> Effect (Stream Event)

Creates a stream from a DOM element and an event type. You can think of this as the FRP equivalent of addEventListener.

clickStream <- streamFromEvent (wrap "click") (toEventTarget buttonElement)

#keyDown Source

keyDown :: Stream KeyboardEvent

Returns a stream that has an occurrence whenever a key is pressed down. The value is the KeyboardEvent associated with the key press.

#keyUp Source

keyUp :: Stream KeyboardEvent

Returns a stream that has an occurrence whenever a key is released. The value is the KeyboardEvent associated with the key press.

#keyPressed Source

keyPressed :: String -> Now (Behavior Boolean)

Returns a behavior that is true when the key is pressed and false then the key is not pressed.

The string specifying the key is a KeyboardEvent.code.

#render Source

render :: forall a. (a -> Effect Unit) -> Behavior a -> Effect Unit

Render the value of a behavior with an effectful render function.

The render function is called on each frame using requestAnimationFrame if the behavior has changed.