Elixir streams provide iterables, but I couldn't find any information on observables (Google was no help here). I'd greatly appreciate it if someone could point me to resources for the same.
You can combine Stream and Enum to write observable-style code. Here's an example of an echo server written in observable fashion:
IO.stream(:stdio, :line)
|> Stream.map(&String.upcase/1)
|> Enum.each(&IO.write(&1))
Basically, for each line you send to standard input, it will be converted to uppercase and then printed back to standard output. This is a simple example, but the point is that all you need to compose an observable is already available via Stream and Enum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With