UrbitEx (UrbitEx v0.5.7) View Source

Main API for the UrbitEx Package. Includes functions to initiate your Urbit session, subscribe to main event sources and set up logic to handle events.

Link to this section Summary

Functions

Sets process as consumer of the Urbit Ship's Eventstream. Every Urbit event will be sent from the Urbit GenServer to the process pid passed.

Fetches pid of the GenServer keeping the session state.

Fetches the current session state from the GenServer.

Starts a recursive loop that reacts to events received from your Urbit ship. Takes a single argument, a function that will process received messages. ## Examples

Starts the Urbit instance without a process link. Takes the url where your ship is running, the +code, and an optional name for the server (handy if you're running multiple ones).

Starts the Urbit instance. Takes the url where your ship is running, the +code, and an optional name for the server (handy if you're running multiple ones).

Subscribes to event streams. Takes a list of subscriptions. If it's a single subscription you want just wrap it in a list. Individual subscriptions are maps: %{app: app, path: path}

Function provided for testing purposes. It will subscribe to the same event streams as the Landscape client does. Set your url and code as module attributes and iterate your handling logic fast. Returns the pid of the GenServer started. Check the state with get_state() and you can browse all events received, etc.

Link to this section Functions

Sets process as consumer of the Urbit Ship's Eventstream. Every Urbit event will be sent from the Urbit GenServer to the process pid passed.

Fetches pid of the GenServer keeping the session state.

Fetches the current session state from the GenServer.

Starts a recursive loop that reacts to events received from your Urbit ship. Takes a single argument, a function that will process received messages. ## Examples

 ```
 function = fn
   %{"json" => json} -> IO.inspect(json)
   _message -> IO.inspect(:other_app)
 end
 UrbitEx.recv(function)
Link to this function

start(url, code, name \\ :urbit_server)

View Source

Starts the Urbit instance without a process link. Takes the url where your ship is running, the +code, and an optional name for the server (handy if you're running multiple ones).

Link to this function

start_link(url, code, name \\ :urbit_server)

View Source

Starts the Urbit instance. Takes the url where your ship is running, the +code, and an optional name for the server (handy if you're running multiple ones).

Examples

iex> {:ok, pid} = UrbitEx.start("http://localhost:8080", "sampel-dozzod-mirtyl-marzod")
Link to this function

subscribe(subscriptions)

View Source

Subscribes to event streams. Takes a list of subscriptions. If it's a single subscription you want just wrap it in a list. Individual subscriptions are maps: %{app: app, path: path}

Function provided for testing purposes. It will subscribe to the same event streams as the Landscape client does. Set your url and code as module attributes and iterate your handling logic fast. Returns the pid of the GenServer started. Check the state with get_state() and you can browse all events received, etc.