- Erlang/OTP 27
- Elixir 1.17.3
My solution prioritized simplicity, so I chose to use IEX to enhance usability.
- Start the interactive Elixir:
$ iex -S mix
- Check the available stocks with the following function:
iex(1)> StockPriceStream.Interactive.get_available_stocks()
# Expected:
{:ok, ["STK1", "STK2", "STK3", "STK4", "STK5"]}
- Choose one stock and start to listening:
iex(2)> StockPriceStream.Interactive.start_listening("STK3")
# Expected:
[info] Subscribed for stock: STK3
[info] Started client subscribed for STK3, PID: #PID<0.223.0>
{:ok, #PID<0.223.0>}
- Stop listening:
iex(3)> StockPriceStream.Interactive.stop_listening("STK3")
Expected:
[info] Terminanting client #PID<0.223.0>
:ok