Bingex.Swap.PriceSocket behaviour (Bingex v0.1.8)

defmodule PriceSource do
  use Bingex.Swap.PriceSocket
  alias Bingex.Swap.PriceSocket

  def start_link(_args \\ []) do
    PriceSocket.start_link(__MODULE__, :state)
  end

  @impl true
  def handle_connect(state) do
    PriceSocket.subscribe(symbol: "BTC-USDT", type: :last)
    {:ok, state}
  end

  @impl true
  def handle_event(type, event, state) do
    IO.inspect({type, event, state})
    {:ok, state}
  end
end

Summary

Callbacks

handle_event(type, event, state)

@callback handle_event(
  type :: :price,
  event :: Bingex.Swap.Model.PriceEvent.t(),
  state :: term()
) :: {:ok, state :: term()} | {:close, state :: term()}

Functions

call(pid, message, delay)

cast(pid, message)

start(module, state, options \\ [])

start_link(module, state, options \\ [])

subscribe(pid \\ self(), params)