Wraith. Widgets. Widget behaviour
(Wraith v0.1.0)
View Source
What a widget is, whatever language it is written in.
A widget is a tiny app embedded in a post with {{widget slug key=value}}.
Every instance (a slug plus an instance id) has one shared state
(a JSON-shaped map) that every reader sees live: an event from one
browser runs handle/4, the new state is saved and broadcast, and
every open page re-renders.
init/1— the state a fresh instance starts with, from the propsrender/3— HTML for a state (metahasinstance,visitor,presence,post); output is the widget's own markup, placed inside a wrapper that carries the instance idhandle/4— a reader's event → the next state (or{:error, why}to refuse it)
Elixir widgets implement this behaviour and are registered in
Wraith.Widgets.builtin_modules/0; Lua widgets implement the same three
functions in a sandbox (Wraith.Widgets.Lua).
Summary
Callbacks
The one-line description shown in the studio.
Types
Callbacks
The one-line description shown in the studio.