View Source BitfinexClient.PubSub (bitfinex_client v0.1.0)

A way to dispatch messages to multiple recipients, based on topics

Link to this section Summary

Functions

Publishes a message in a specific topic

Starts the PubSub manager

Subscribe the current process to a topic

Link to this section Functions

Link to this function

publish(topic, message, opts \\ [])

View Source
@spec publish(atom(), term(), list()) :: :ok

Publishes a message in a specific topic

examples

Examples

iex> pub_sub_name = :pub_sub_publish_doctest
...> BitfinexClient.PubSub.start_link(pub_sub_name: pub_sub_name)
...> BitfinexClient.PubSub.subscribe(:btc_usd_ticker, pub_sub_name: pub_sub_name)
...> BitfinexClient.PubSub.publish(:btc_usd_ticker, 19565, pub_sub_name: pub_sub_name)
...> receive do
...>   price -> price
...> end
19565
@spec start_link(list()) :: {:ok, pid()} | {:error, term()}

Starts the PubSub manager

Link to this function

subscribe(topic, opts \\ [])

View Source
@spec subscribe(atom(), list()) ::
  {:ok, pid()} | {:error, {:already_registered, pid()}}

Subscribe the current process to a topic

examples

Examples

iex> BitfinexClient.PubSub.start_link()
...> BitfinexClient.PubSub.subscribe(:btc_usd_ticker)
...> |> elem(0)
:ok