Breeze.Runtime (Breeze v0.5.0)

Copy Markdown View Source

Generic runtime tooling for Breeze applications.

Runtime state is an opaque in-VM value that can be captured, used to replace a running view tree, or started as an isolated runtime. Development tools can decide when to capture it through Breeze.Runtime.Hook without Breeze imposing storage, history, or debugger semantics.

Replacing or starting from runtime state does not invoke mount/2.

Summary

Functions

Exports opaque state from a running Breeze server.

Displays a frame in a running Breeze application.

Dispatches a named event and payload to an isolated runtime.

Dispatches a message to an isolated runtime's handle_info/2 callback.

Dispatches decoded terminal input to an isolated runtime.

Pauses the current runtime frame until the next application interaction.

Renders an isolated runtime and returns its terminal content.

Replaces a running Breeze application's view runtime with exported state.

Returns rendered content, view metadata, and screen dimensions.

Starts an isolated runtime from exported state.

Stops an isolated runtime.

Types

t()

@type t() :: %Breeze.Runtime{pid: pid(), terminal: Termite.Terminal.t()}

Functions

capture_state(server_pid, opts \\ [])

@spec capture_state(
  pid(),
  keyword()
) :: {:ok, Breeze.Runtime.State.t()} | {:error, term()}

Exports opaque state from a running Breeze server.

display_frame(server_pid, frame, opts \\ [])

@spec display_frame(pid(), :live | map(), keyword()) :: :ok | {:error, term()}

Displays a frame in a running Breeze application.

Pass :live as the frame to return to the application's current output. Displaying another frame pauses the view runtime until live output is restored.

event(runtime, change, event)

@spec event(t(), term(), map()) :: term()

Dispatches a named event and payload to an isolated runtime.

info(runtime, message)

@spec info(t(), term()) :: term()

Dispatches a message to an isolated runtime's handle_info/2 callback.

input(runtime, input, opts \\ [])

@spec input(t(), term(), keyword()) :: term()

Dispatches decoded terminal input to an isolated runtime.

pause(server_pid)

@spec pause(pid()) :: :ok | {:error, term()}

Pauses the current runtime frame until the next application interaction.

render(runtime, opts \\ [])

@spec render(
  t(),
  keyword()
) :: {:ok, String.t()} | term()

Renders an isolated runtime and returns its terminal content.

replace_state(server_pid, runtime_state)

@spec replace_state(pid(), Breeze.Runtime.State.t()) :: :ok | {:error, term()}

Replaces a running Breeze application's view runtime with exported state.

snapshot(runtime, opts \\ [])

@spec snapshot(
  t(),
  keyword()
) :: {:ok, map()} | term()

Returns rendered content, view metadata, and screen dimensions.

start_from_state(runtime_state, opts \\ [])

@spec start_from_state(
  Breeze.Runtime.State.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Starts an isolated runtime from exported state.

stop(runtime)

@spec stop(t()) :: :ok

Stops an isolated runtime.