Phoenix.React.Runtime behaviour (Phoenix.React v0.5.2)

View Source

Phoenix.React.Runtime

Manage the runtime of the React Render Server

If in dev mode, it will start a file watcher to watch the component directory. Reload the server when the component file changed with a throttle time at 3s.

@behaviour Phoenix.React.Runtime

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for DynamicSupervisor.init/1.

Types

component()

@type component() :: binary()

html()

@type html() :: binary()

path()

@type path() :: binary()

t()

@type t() :: %Phoenix.React.Runtime{
  cd: path(),
  component_base: path(),
  port: port(),
  render_timeout: integer(),
  server_js: path()
}

Callbacks

config()

@callback config() :: list()

render_to_readable_stream(component, map, from, t)

@callback render_to_readable_stream(component(), map(), GenServer.from(), t()) ::
  {:reply, {:ok, html()}, t()} | {:reply, {:error, term()}, t()}

render_to_static_markup(component, map, from, t)

@callback render_to_static_markup(component(), map(), GenServer.from(), t()) ::
  {:reply, {:ok, html()}, t()} | {:reply, {:error, term()}, t()}

render_to_string(component, map, from, t)

@callback render_to_string(component(), map(), GenServer.from(), t()) ::
  {:reply, {:ok, html()}, t()} | {:reply, {:error, term()}, t()}

start(list)

@callback start(component_base: path(), render_timeout: integer()) :: port()

start_file_watcher(path)

@callback start_file_watcher(path()) :: :ok

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(init_arg)

Callback implementation for DynamicSupervisor.init/1.

start_file_watcher(args)

start_link(init_arg)

start_runtime(runtime, args)