gen_frp v0.1.0 GenFRP

The main GenFRP module.

GenFRP wraps GenServer, which means that a separate process is spawned using start or startlink. After this, the other functions in this module can be used to send messages to this process. The idea is to: - start a GenFRP process with your desired GenFRP behaviour. - Send events usingsend_eventto this process, which will update its state. - At some point,renderthe state the process has during that time. The results ofrenderare cached, to restrict the amount of work that is done. Instead of sending events manually,register_callback` can be used to register _callbacks that might send an event whenever they are triggered. A callback is basically a wrapper with some setup and some tear-down code.

Summary

Functions

A simple function that just dumps the full internal state of the GenFRP process. Should only be used for debugging purposes; might be removed in future releases

Deregisters a previously-registered callback

Adds the given callback to the given FRP process pid

Requests to render the internal state of pid

Sends the given event (which might be anything that your FRP implementation expects in its implementation of the GenFRP.Behaviour.update/2 function) to the FRP process pid

Starts the given frp_module in a as a GenFRP process

Atomically starts the given frp_module as a GenFRP process and sets up a link to it; if it crashes, the process that started it will also crash

Functions

debug(pid)

A simple function that just dumps the full internal state of the GenFRP process. Should only be used for debugging purposes; might be removed in future releases.

deregister_callback(pid, callback)

Deregisters a previously-registered callback.

To deregister a previously-registered callback, simply specify the exact same callback to this function (or reconstruct one from the same original parameters).

register_callback(pid, callback)

Adds the given callback to the given FRP process pid.

See the GenFRP.Callback module for more information.

render(pid)

Requests to render the internal state of pid.

Internally, the GenFRP.Behaviour’s render/1 function will be called on your FRP implementation.

But this will only happen if the state has changed since the last call to render. If it has not, then the older, cached state will be returned.

send_event(pid, event)

Sends the given event (which might be anything that your FRP implementation expects in its implementation of the GenFRP.Behaviour.update/2 function) to the FRP process pid.

start(frp_module)

Starts the given frp_module in a as a GenFRP process.

It returns the PID of the started process, which is to be used for most of the other methods in this module.

start(frp_module, initial_state)
start_link(frp_module)

Atomically starts the given frp_module as a GenFRP process and sets up a link to it; if it crashes, the process that started it will also crash.

start_link(frp_module, initial_state)