Lavash.State (Lavash v0.4.0-rc.1)

Copy Markdown View Source

State hydration and management.

Summary

Functions

Hydrates forms - creates implicit ephemeral state for form params.

Hydrates from: :session state from the Plug session map. Each field's :session_key (defaults to the field name as a string) is looked up; if absent, the field's :default is used. Session state is read once at mount and isn't re-read on subsequent events — like from: :ephemeral but seeded from the session at mount time.

Hydrates socket fields from connect params. Socket fields survive reconnects via JS client sync.

Functions

hydrate_ephemeral(socket, module)

hydrate_forms(socket, module)

Hydrates forms - creates implicit ephemeral state for form params.

hydrate_session(socket, module, session)

Hydrates from: :session state from the Plug session map. Each field's :session_key (defaults to the field name as a string) is looked up; if absent, the field's :default is used. Session state is read once at mount and isn't re-read on subsequent events — like from: :ephemeral but seeded from the session at mount time.

hydrate_socket(socket, module, connect_params)

Hydrates socket fields from connect params. Socket fields survive reconnects via JS client sync.

hydrate_url(socket, module, params)