Channel
public struct Channel<T>
A Channel
is a frontend for receiving values written to a ChannelWriter
.
A Channel
provides an interface for adding handlers for these values,
as well as ways to create new Channels
that
change values before passing them to handlers.
Each handler is only ever called once;
with the next value the channel receives after adding it.
-
Undocumented
Declaration
Swift
public struct Channel<T>
-
Undocumented
Declaration
Swift
public struct Channel<T>
-
Undocumented
Declaration
Swift
public struct Channel<T>
-
Functor fmap.
Maps this channel to a channel of another type.
Declaration
Swift
public func map<U>(mapper: T -> U) -> Channel<U>
Parameters
mapper
The function to map values of this channel with.
Return Value
A channel that receives mapped values from this channel.
-
Applicative <*>
Applies functions in another channel to values passed to this channel. After
mappers
passes a function, the next value passed to self is passed to that function. The resulting value is passed to the returned channel.Declaration
Swift
public func apply<U>(mappers: Channel<T -> U>) -> Channel<U>
Parameters
mappers
The channel of functions to map with.
Return Value
A channel that receives values that have been passed through functions received from the
mappers
channel.
-
Monad return.
Declaration
Swift
public static func of<T>(value: T) -> Channel<T>
Parameters
value
The value to make a channel around.
Return Value
A channel that calls all handlers with the same value.
-
Monad bind.
Maps each value received by this channel to a channel, and passes values of that channel to the returned channel.
Declaration
Swift
public func flatMap<U>(mapper: T -> Channel<U>) -> Channel<U>
Parameters
mapper
The function to map values with.
Return Value
A channel that will receive all values of the channels that the mapper returns.
-
Declaration
Swift
public static func empty<T>() -> Channel<T>
Return Value
A channel that never receives any values.
-
Declaration
Swift
public func appended(other: Channel<T>) -> Channel<T>
Parameters
other
A channel to append with this one.
Return Value
A channel that receives all values that either this channel or the
other
channel receives.
-
Declaration
Swift
public func filter(predicate: T -> Bool) -> Channel<T>
Parameters
predicate
A test for values received by this channel.
Return Value
A channel that only receives values that pass the predicate.
-
Declaration
Swift
public func addHandler(handler: T -> ())
Parameters
handler
Receives the next value this channel receives.
-
Declaration
Swift
public func next() -> Future<T>
Return Value
A future representing the next value this channel receives.