Events
"on": {"click": "toggle"} names a server event. When it fires, the handler's params carry the node id, the event kind, its payload, and — because the server kept the tree — the node's props. Nothing a client sends is trusted: three things are checked before a handler runs — the node exists in the tree this server last sent, it carries a handler of that kind naming that name, and the payload is the shape the kind declares. An event that fails any of them is dropped, not an error and not the end of the session: an event may arrive from a client one render behind, naming a node that existed a moment ago, and closing the session there would cost somebody their application for a mouse movement — while making one malformed frame an attack on every reader. EUI_TRACE=1 prints what was dropped and why.
Every event kind
29 of them. A kind the view has not declared cannot arrive.
| Kind | Fires when |
|---|---|
click | A press and release on the node. |
double_click | Two clicks inside the double-click interval. |
pointer_down | The pointer went down on the node. |
pointer_up | And came back up. |
pointer_move | The pointer moved while over the node. |
pointer_enter | The pointer entered the node. |
pointer_leave | The pointer left it. |
key_down | A key went down while the node had focus. |
key_up | And came back up. |
text_input | Text was typed or composed into the node. |
focus | The node took keyboard focus. |
blur | It lost focus. |
change | A field's value settled. |
submit | A form-shaped group was submitted. |
scroll | The node was scrolled. |
resize | The node's box changed size. |
context_menu | The secondary button, or its platform equivalent. |
drag_start | A drag began on the node. |
drag_over | A drag passed over it. |
drop | A drag was released on it. |
long_press | A press held past the platform threshold. |
window | The window itself changed — moved, resized, closed. |
ended | Media finished playing. |
time_update | Media playback advanced. |
wake | The session's own clock fired. |
file_pick | A file dialog returned a choice. |
file_save | A save dialog returned a destination. |
location | A position fix from the device. Phone only. |
nfc_tag | An NFC tag came within range. Phone only. |
file_pick, file_save, location and nfc_tag are answered by the client, and the last two are compiled only for a phone: a desktop has no tag reader and no positioning it can reach.
Waking a session
A component may ask to be woken on a clock — the wake event. On its own that makes every window a poller: it learns what someone else did only when its own clock next fires, and spends a render per period discovering that nothing happened.
eui_wake(component) is the other half — it renders every other live session of a component immediately, from wherever the change was written.
def send(state, params)
Message.create({ "room": state["room"], "body": params["value"] })
eui_wake("chat") # every other window showing this component, now
state
end