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
mapperThe 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
mapperspasses 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
mappersThe channel of functions to map with.
Return Value
A channel that receives values that have been passed through functions received from the
mapperschannel.
-
Monad return.
Declaration
Swift
public static func of<T>(value: T) -> Channel<T>Parameters
valueThe 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
mapperThe 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
otherA channel to append with this one.
Return Value
A channel that receives all values that either this channel or the
otherchannel receives.
-
Declaration
Swift
public func filter(predicate: T -> Bool) -> Channel<T>Parameters
predicateA 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
handlerReceives the next value this channel receives.
-
Declaration
Swift
public func next() -> Future<T>Return Value
A future representing the next value this channel receives.
Channel Struct Reference