View Source Breeze.Server (Breeze v0.2.0)

This module powers the GenServer responsible for running the application.

Consider the following Breeze Application:

defmodule Demo do
  use Breeze.View

  def mount(_opts, term), do: {:ok, assign(term, counter: 0)}

  def render(assigns) do
    ~H"<box>Counter: <%= @counter %></box>"
  end

  def handle_event(_, %{"key" => "ArrowUp"}, term) do
    {:noreply, assign(term, counter: term.assigns.counter + 1)}
  end

  def handle_event(_, %{"key" => "ArrowDown"}, term) do
    {:noreply, assign(term, counter: term.assigns.counter - 1)}
  end

  def handle_event(_, %{"key" => "q"}, term) do
    {:stop, term}
  end

  def handle_event(_, _, term) do
    {:noreply, term}
  end
end

This can be started directly with:

Breeze.Server.start_link(view: Focus)

Or in a supervision tree:

children = [
  {Breeze.Server, view: Demo}
]

Summary

Functions

Returns a specification to start this module under a supervisor.

Start the Breeze application.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Start the Breeze application.

Valid options are:

  • :view - the view to run. This is required
  • :hide_cursor - hide the cursor on start. Defaults to false