Module

Bonsai.Event

Package
purescript-bonsai
Repository
grmble/purescript-bonsai

Event listener utilities

For maximum performance, event handlers attached to the virtual DOM should be comparable by object identity. For this, you have call on with a top level function event decoder.

So for top VDOM diff/patching performance, instead of using onInput, you would make a top level function

decodeXxx event = eventDecoder Xxx targetValue

-- use it like on "input" decodeXxx

Or you might just have a single event handler on a parent element and look at the event target.

#onInput Source

onInput :: Property String

Event listener property for the input event.

Should be defined on an input. Will call the message constructor with the current value of the input element.

#onClick Source

onClick :: forall msg. msg -> Property msg

Event listener property for the click event.

#onClickWithOptions Source

onClickWithOptions :: forall msg. Options -> msg -> Property msg

#onSubmit Source

onSubmit :: Property (StrMap String)

Event listener property for the submit event.

Should be defined on the form. Will prevent default and stop propagation and will call the constructor with a map of the current form values.

#onEnter Source

onEnter :: forall msg. msg -> Property msg

Emit commands on enter key presses

#preventDefaultStopPropagation Source

#targetValue Source

targetValue :: EventDecoder String

Read the value of the target input element

#targetValues Source

targetValues :: EventDecoder (StrMap String)

Read the names and values of target form, for form events.

#ignoreEscape Source

ignoreEscape :: EventDecoder Unit

Event decoder returns unit or fails

hack or no hack?