Current section

18 Versions

Jump to

Compare versions

10 files changed
+99 additions
-199 deletions
  @@ -90,36 +90,22 @@ iex(2)> wallet
90 90 This example will do a subscription onto the channel `market_stats`, and print out the received messages.
91 91
92 92 ``` elixir
93 - defmodule WatchMarketStats do
94 - use GenServer
95 -
96 - def start_link(state) do
97 - GenServer.start_link(__MODULE__, state, name: __MODULE__)
98 - end
99 -
100 - ## Callbacks
101 -
102 - def init(stack) do
103 - # Start listening on the `market_stats` channel
104 - Tradehub.Stream.market_stats()
105 -
106 - # Register myself as the client to handle message from the channel
107 - Phoenix.PubSub.subscribe(Tradehub.PubSub, "market_stats")
108 -
109 - {:ok, stack}
110 - end
111 -
112 - # Handle latest message from the `market_stats` channel
113 - def handle_info(msg, state) do
114 - IO.puts("Receive message -- #{inspect(msg)}")
93 + defmodule MarketStatsObserver do
94 + use Tradehub.Stream,
95 + topics: [
96 + "market_stats" # Subscribe the topic `market_stats`
97 + ]
115 98
99 + # Handle recent messages from the topic
100 + def handle_info(message, state) do
101 + IO.puts("#{message}")
116 102 {:noreply, state}
117 103 end
118 104 end
119 105 ```
120 106
121 107 ``` elixir
122 - iex(1)> WatchMarketStats.start_link {}
108 + iex(1)> MarketStatsObserver.start_link
123 109 ```
124 110
125 111 Full documentation can be found at [https://hexdocs.pm/tradehub](https://hexdocs.pm/tradehub).
  @@ -59,4 +59,4 @@
59 59 {<<"optional">>,false},
60 60 {<<"repository">>,<<"hexpm">>},
61 61 {<<"requirement">>,<<"~> 2.0">>}]]}.
62 - {<<"version">>,<<"0.1.13">>}.
62 + {<<"version">>,<<"0.1.14">>}.
  @@ -13,8 +13,6 @@ defmodule Tradehub.Exchange do
13 13
14 14 iex> Tradehub.Exchange.tokens
15 15
16 - iex> Tradehub.Exchange.tokens!
17 -
18 16 """
19 17
20 18 @spec tokens :: {:error, HTTPoison.Error.t()} | {:ok, list(Tradehub.token())}
  @@ -36,8 +34,6 @@ defmodule Tradehub.Exchange do
36 34
37 35 iex> Tradehub.Exchange.token("swth")
38 36
39 - iex> Tradehub.Exchange.token!("swth")
40 -
41 37 """
42 38
43 39 @spec token(String.t()) :: {:error, HTTPoison.Error.t()} | {:ok, Tradehub.token()}
  @@ -59,8 +55,6 @@ defmodule Tradehub.Exchange do
59 55
60 56 iex> Tradehub.Exchange.markets
61 57
62 - iex> Tradehub.Exchange.markets!
63 -
64 58 """
65 59
66 60 @typedoc """
  @@ -100,8 +94,6 @@ defmodule Tradehub.Exchange do
100 94
101 95 iex> Tradehub.Exchange.market("swth_eth1")
102 96
103 - iex> Tradehub.Exchange.market!("swth_eth1")
104 -
105 97 """
106 98
107 99 @spec market(String.t()) :: {:ok, Tradehub.market()} | {:error, HTTPoison.Error.t()}
  @@ -128,8 +120,6 @@ defmodule Tradehub.Exchange do
128 120
129 121 iex> Tradehub.Exchange.orderbook("swth_eth1")
130 122
131 - iex> Tradehub.Exchange.orderbook!("swth_eth1")
132 -
133 123 """
134 124
135 125 @spec orderbook(String.t(), integer) :: {:ok, Tradehub.orderbook()} | {:error, HTTPoison.Error.t()}
  @@ -154,8 +144,6 @@ defmodule Tradehub.Exchange do
154 144
155 145 iex> Tradehub.Exchange.oracle_results
156 146
157 - iex> Tradehub.Exchange.oracle_results!
158 -
159 147 """
160 148
161 149 @type oracle_id :: String.t()
  @@ -180,8 +168,6 @@ defmodule Tradehub.Exchange do
180 168
181 169 iex> Tradehub.Exchange.oracle_result("SIDXBTC")
182 170
183 - iex> Tradehub.Exchange.oracle_result!("SIDXBTC")
184 -
185 171 """
186 172
187 173 @spec oracle_result(oracle_id) :: {:ok, Tradehub.oracle()} | {:error, HTTPoison.Error.t()}
  @@ -203,8 +189,6 @@ defmodule Tradehub.Exchange do
203 189
204 190 iex> Tradehub.Exchange.insurance_balances
205 191
206 - iex> Tradehub.Exchange.insurance_balances!
207 -
208 192 """
209 193
210 194 @spec insurance_balances :: {:ok, list(Tradehub.amount())} | {:error, HTTPoison.Error.t()}
  @@ -12,8 +12,6 @@ defmodule Tradehub.Fee do
12 12
13 13 iex> Tradehub.Fee.txns_fees
14 14
15 - iex> Tradehub.Fee.txns_fees!
16 -
17 15 """
18 16
19 17 @spec txns_fees :: {:ok, Tradehub.txns_fees()} | {:error, HTTPoison.Error.t()}
  @@ -35,8 +33,6 @@ defmodule Tradehub.Fee do
35 33
36 34 iex> Tradehub.Fee.current_fee("swth")
37 35
38 - iex> Tradehub.Fee.current_fee!("swth")
39 -
40 36 """
41 37
42 38 @spec current_fee(denom :: String.t()) :: {:ok, Tradehub.withdrawal_fee()} | {:error, HTTPoison.Error.t()}
  @@ -12,8 +12,6 @@ defmodule Tradehub.Protocol do
12 12
13 13 iex> Tradehub.Protocol.status
14 14
15 - iex> Tradehub.Protocol.status!
16 -
17 15 """
18 16
19 17 @spec status :: {:ok, Tradehub.protocol_status()} | {:error, HTTPoison.Error.t()}
  @@ -35,8 +33,6 @@ defmodule Tradehub.Protocol do
35 33
36 34 iex> Tradehub.Protocol.block_time
37 35
38 - iex> Tradehub.Protocol.block_time!
39 -
40 36 """
41 37
42 38 @spec block_time :: {:ok, String.t()} | {:error, HTTPoison.Error.t()}
  @@ -58,8 +54,6 @@ defmodule Tradehub.Protocol do
58 54
59 55 iex> Tradehub.Protocol.validators
60 56
61 - iex> Tradehub.Protocol.validators!
62 -
63 57 """
64 58
65 59 @spec validators :: {:ok, list(Tradehub.validator())} | {:error, HTTPoison.Error.t()}
  @@ -81,8 +75,6 @@ defmodule Tradehub.Protocol do
81 75
82 76 iex> Tradehub.Protocol.delegation_rewards("tswth174cz08dmgluavwcz2suztvydlptp4a8f8t5h4t")
83 77
84 - iex> Tradehub.Protocol.delegation_rewards!("tswth174cz08dmgluavwcz2suztvydlptp4a8f8t5h4t")
85 -
86 78 """
87 79
88 80 @spec delegation_rewards(String.t()) :: {:ok, Tradehub.delegation_rewards()} | {:error, HTTPoison.Error.t()}
  @@ -107,8 +99,6 @@ defmodule Tradehub.Protocol do
107 99
108 100 iex> Tradehub.Protocol.blocks
109 101
110 - iex> Tradehub.Protocol.blocks!
111 -
112 102 """
113 103
114 104 @typedoc """
  @@ -149,8 +139,6 @@ defmodule Tradehub.Protocol do
149 139
150 140 iex> Tradehub.Protocol.transactions
151 141
152 - iex> Tradehub.Protocol.transactions!
153 -
154 142 """
155 143
156 144 @typedoc """
  @@ -201,8 +189,6 @@ defmodule Tradehub.Protocol do
201 189
202 190 iex> Tradehub.Protocol.transaction("A93BEAC075562D4B6031262BDDE8B9A720346A54D8570A881E3671FEB6E6EFD4")
203 191
204 - iex> Tradehub.Protocol.transaction!("A93BEAC075562D4B6031262BDDE8B9A720346A54D8570A881E3671FEB6E6EFD4")
205 -
206 192 """
207 193
208 194 @spec transaction(String.t()) :: {:ok, Tradehub.transaction()} | {:error, HTTPoison.Error.t()}
  @@ -248,8 +234,6 @@ defmodule Tradehub.Protocol do
248 234
249 235 iex> Tradehub.Protocol.total_balances
250 236
251 - iex> Tradehub.Protocol.total_balances!
252 -
253 237 """
254 238
255 239 @spec total_balances :: {:ok, list(Tradehub.protocol_balance())} | {:error, HTTPoison.Error.t()}
  @@ -271,8 +255,6 @@ defmodule Tradehub.Protocol do
271 255
272 256 iex> Tradehub.Protocol.external_transfers("tswth174cz08dmgluavwcz2suztvydlptp4a8f8t5h4t")
273 257
274 - iex> Tradehub.Protocol.external_transfers!("tswth174cz08dmgluavwcz2suztvydlptp4a8f8t5h4t")
275 -
276 258 """
277 259
278 260 @spec external_transfers(String.t()) :: {:ok, list(Tradehub.transfer_record())} | {:error, HTTPoison.Error.t()}
Loading more files…