Packages

WIP - Stream data from enumerables in a controller manner!

Current section

Files

Jump to
pour lib pour.ex
Raw

lib/pour.ex

defmodule Pour do
@moduledoc ~S"""
"""
@spec stream(Enumerables.t() | [Enumerables.t()], keyword()) :: Enumerable.t()
def stream(enumerables, opts \\ [])
def stream([] = enumerable, opts) do
stream([enumerable], opts)
end
def stream([_ | _] = enumerables, opts) do
start = if Keyword.get(opts, :link, true), do: :start_link, else: :start
args = [enumerables, opts]
case apply(Pour.Sink, start, args) do
{:ok, pid} ->
Pour.Sink.stream(pid)
{:error, reason} ->
exit({reason, {__MODULE__, :stream}})
end
end
end