Strom.Sink behaviour (strom v0.9.1)
View SourceRuns a given steam and call
origin on each even in stream.
By default it runs the stream asynchronously (in Task.async
).
One can pass true
a the third argument to the Sink.new/3
function to run a stream synchronously.
## Example
iex> alias Strom.{Sink, Sink.WriteLines}
iex> sink = :strings |> Sink.new(WriteLines.new("test/data/sink.txt"), sync: true) |> Sink.start()
iex> %{} = Sink.call(%{strings: ["a", "b", "c"]}, sink)
iex> File.read!("test/data/sink.txt")
"a\nb\nc\n"
Sink defines a @behaviour
. One can easily implement their own sinks.
See Strom.Sink.Writeline
, Strom.Sink.IOPuts
, Strom.Sink.Null