Kino.Frame (Kino v0.4.0) View Source
A widget wrapping a static output.
This widget serves as a placeholder for a regular output, so that it can be dynamically replaced at any time.
Also see Kino.animate/3
which offers a convenience on
top of this widget.
Examples
widget = Kino.Frame.new() |> tap(&Kino.render/1)
for i <- 1..100 do
Kino.Frame.render(widget, i)
Process.sleep(50)
end
Or with a scheduled task in the background.
widget = Kino.Frame.new() |> tap(&Kino.render/1)
Kino.Frame.periodically(widget, 50, 0, fn i ->
Kino.Frame.render(widget, i)
{:cont, i + 1}
end)
Link to this section Summary
Functions
Starts a widget process.
Registers a callback to run periodically in the widget process.
Renders the given term within the frame.
Link to this section Types
Specs
t() :: %Kino.Frame{pid: pid()}
Link to this section Functions
Specs
new() :: t()
Starts a widget process.
Specs
periodically(t(), pos_integer(), term(), (term() -> {:cont, term()} | :halt)) :: :ok
Registers a callback to run periodically in the widget process.
The callback is run every interval_ms
milliseconds and receives
the accumulated value. The callback should return either of:
{:cont, acc}
- the continue with the new accumulated value:halt
- to no longer schedule callback evaluation
The callback is run for the first time immediately upon registration.
Specs
Renders the given term within the frame.
This works similarly to Kino.render/1
, but the frame
widget only shows the last rendered result.