421anon/elm-flow/1.0.0

NOTE: the latest version is 6.0.2

Flow.Channel

Channel primitives for connecting external event sources to Flow.

Use connect when you have both a subscription source and an optional command to kick off/attach the channel, or join when you only need subscriptions. Then consume events with Flow.await, Flow.awaitUntil, or Flow.subscribe.

type Channel s a

Opaque channel handle that describes how to connect an external event source to a Flow pipeline.

type alias ChannelKey =
String

Per-subscription key passed to channel ports.

Use this to correlate a subscribe request and the values emitted for it.

((a -> Maybe (Flow s a)) -> Sub (Maybe (Flow s a)))
-> (ChannelKey -> Cmd (Flow s a))
-> Channel s a

Build a channel from both a subscription source and a command that starts or attaches it.

join : ((a -> Maybe (Flow s a)) -> Sub (Maybe (Flow s a))) -> Channel s a

Build a channel from subscriptions only.

Use this when no startup command is required.

filter : (ChannelKey -> a -> Bool) -> Channel s a -> Channel s a

Filter events for a channel using both the generated ChannelKey and the event payload.

accept : (a -> Flow s ()) -> Channel s a -> Flow s a

Subscribe to a channel and handle every incoming event indefinitely.

acceptOne : Channel s a -> Flow s a

Wait for a single event from a channel and return it.

acceptUntil : (a -> Bool) -> Channel s a -> Flow s a

Wait for channel events until the predicate returns True, then return that final event.