FlattenStrategy

public struct FlattenStrategy

Describes how a stream of inner streams should be flattened into a stream of values.

  • The stream of streams is merged, so that any value sent by any of the inner streams is forwarded immediately to the flattened stream of values.

    The flattened stream of values completes only when the stream of streams, and all the inner streams it sent, have completed.

    Any interruption of inner streams is treated as completion, and does not interrupt the flattened stream of values.

    Any failure from the inner streams is propagated immediately to the flattened stream of values.

    Declaration

    Swift

    public static let merge: FlattenStrategy
  • The stream of streams is concatenated, so that only values from one inner stream are forwarded at a time, in the order the inner streams are received.

    In other words, if an inner stream is received when a previous inner stream has yet terminated, the received stream would be enqueued.

    The flattened stream of values completes only when the stream of streams, and all the inner streams it sent, have completed.

    Any interruption of inner streams is treated as completion, and does not interrupt the flattened stream of values.

    Any failure from the inner streams is propagated immediately to the flattened stream of values.

    Declaration

    Swift

    public static let concat: FlattenStrategy
  • The stream of streams is merged with the given concurrency cap, so that any value sent by any of the inner streams on the fly is forwarded immediately to the flattened stream of values.

    In other words, if an inner stream is received when a previous inner stream has yet terminated, the received stream would be enqueued.

    The flattened stream of values completes only when the stream of streams, and all the inner streams it sent, have completed.

    Any interruption of inner streams is treated as completion, and does not interrupt the flattened stream of values.

    Any failure from the inner streams is propagated immediately to the flattened stream of values.

    Precondition

    limit > 0.

    Declaration

    Swift

    public static func concurrent(limit: UInt) -> FlattenStrategy
  • Forward only values from the latest inner stream sent by the stream of streams. The active inner stream is disposed of as a new inner stream is received.

    The flattened stream of values completes only when the stream of streams, and all the inner streams it sent, have completed.

    Any interruption of inner streams is treated as completion, and does not interrupt the flattened stream of values.

    Any failure from the inner streams is propagated immediately to the flattened stream of values.

    Declaration

    Swift

    public static let latest: FlattenStrategy
  • Forward only events from the first inner stream that sends an event. Any other in-flight inner streams is disposed of when the winning inner stream is determined.

    The flattened stream of values completes only when the stream of streams, and the winning inner stream, have completed.

    Any interruption of inner streams is propagated immediately to the flattened stream of values.

    Any failure from the inner streams is propagated immediately to the flattened stream of values.

    Declaration

    Swift

    public static let race: FlattenStrategy