Packages

Elixir HTTP/Websockets client library for official Steemit API and standard steemd JSONRPC interface. Includes module for pseudo realtime streaming of block, transaction and operation events.

Current section

Files

Jump to
steemex lib steemex id_agent.ex
Raw

lib/steemex/id_agent.ex

defmodule Steemex.IdAgent do
@moduledoc """
Holds state with data linking jsonrpc call ids and params for pattern
matching in the handler
"""
def start_link do
Agent.start_link(fn -> Map.new end, name: __MODULE__)
end
def get(id) do
Agent.get_and_update(__MODULE__, fn map ->
map |> Map.pop(String.to_integer(id))
end)
end
def put(id, params) do
Agent.update(__MODULE__, fn map ->
Map.put(map, id, params)
end)
end
end