View Source Kino.JS.Live.Context (Kino v0.5.2)
State available in Kino.JS.Live
server callbacks.
Properties
:assigns
- custom server state kept across callback calls:origin
- an opaque identifier of the client that triggered the given action. It is set inKino.JS.Live.handle_connect/1
andKino.JS.Live.handle_event/3
Link to this section Summary
Functions
Stores key-value pairs in the state.
Sends an event to the client.
Updates an existing key with the given function in the state.
Link to this section Types
Specs
origin() :: nil | term()
Specs
Link to this section Functions
Specs
assign(t(), Enumerable.t()) :: t()
Stores key-value pairs in the state.
Examples
assign(ctx, count: 1, timestamp: DateTime.utc_now())
Specs
Sends an event to the client.
The event is dispatched to the registered JavaScript callback on all connected clients.
Examples
broadcast_event(ctx, "new_point", %{x: 10, y: 10})
Specs
Updates an existing key with the given function in the state.
Examples
assign(ctx, count: 1, timestamp: DateTime.utc_now())