EventSource

public protocol EventSource : Completing, EventController, Updating, Sequence

A base protocol of object that update and complete

  • a sequence iterator type. Enables conformance to Sequence behaviors

    Declaration

    Swift

    associatedtype Iterator = ChannelIterator<Self.Update, Self.Success>
  • amount of currently stored updates

    Declaration

    Swift

    var bufferSize: Int { get }
  • maximal amount of updates store

    Declaration

    Swift

    var maxBufferSize: Int { get }
  • internal use only**

    Declaration

    Swift

    func makeHandler(executor: Executor, _ block: @escaping (_ event: Event, _ originalExecutor: Executor) -> Void) -> AnyObject?
  • Makes a suspendable channel Returned channel will be suspended by a signal from a suspensionController

    Declaration

    Swift

    func suspendable<T: EventSource>(
      _ suspensionController: T,
      suspensionBufferSize: Int = 1,
      isSuspendedInitially: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>
      where T.Update == Bool

    Parameters

    suspensionController

    EventSource to control suspension with. Updates of the returned channel are delivered when the lates update for suspensionController was true.

    suspensionBufferSize

    amount of updates to buffer when channel is suspended

    isSuspendedInitially

    tells if returned channel is initially suspended

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    suspendable channel.

  • Picks latest update value of the channel every interval and sends it

    Declaration

    Swift

    func debounce(
      deadline: DispatchTime = DispatchTime.now(),
      interval: Double,
      leeway: DispatchTimeInterval? = nil,
      qos: DispatchQoS.QoSClass = .default,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    deadline

    to start picking peridic values after

    interval

    interfal for picking latest update values

    leeway

    leeway for timer

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need

    Return Value

    channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<T, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      behavior: ChannelFlatteningBehavior,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ strongContext: C, _ update: Update) throws -> Future<T>
      ) -> Channel<T, Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Completion of a future will be used as update value of transformed channel

    strongContext

    context restored from weak reference to specified context

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<T>(
      executor: Executor = .primary,
      behavior: ChannelFlatteningBehavior,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ update: Update) throws -> Future<T>
      ) -> Channel<T, Success>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Completion of a future will be used as update value of transformed channel

    update

    Update to transform

    Return Value

    transformed channel

  • _onEvent(executor:_:) Extension method

    internal use only**

    Declaration

    Swift

    func _onEvent(
      executor: Executor,
      _ block: @escaping (_ event: Event, _ originalExecutor: Executor) -> Void
      ) -> Self
  • internal use only**

    Declaration

    Swift

    func _onEvent<C: ExecutionContext>(
      context: C,
      executor: Executor?,
      _ block: @escaping (_ strongContext: C, _ event: Event, _ originalExecutor: Executor) -> Void
      ) -> Self
  • onEvent(executor:_:) Extension method

    Subscribes for buffered and new values (both update and completion) for the channel

    Declaration

    Swift

    @discardableResult
    func onEvent(
      executor: Executor = .primary,
      _ block: @escaping (_ event: Event) -> Void
      ) -> Self

    Parameters

    executor

    to execute block on

    block

    to execute. Will be called multiple times

    event

    received by the channel

  • onEvent(context:executor:_:) Extension method

    Subscribes for buffered and new values (both update and completion) for the channel

    Declaration

    Swift

    @discardableResult
    func onEvent<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      _ block: @escaping (_ strongContext: C, _ event: Event) -> Void
      ) -> Self

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    block

    to execute. Will be called multiple times

    strongContext

    context restored from weak reference to specified context

    event

    received by the channel

  • extractAll() Extension method

    Makes a future of accumulated updates and completion

    Declaration

    Swift

    func extractAll() -> Future<(updates: [Update], completion: Fallible<Success>)>
  • Binds events to a specified ProducerProxy

    Declaration

    Swift

    func bindEvents<T: EventDestination>(
      _ eventDestination: T,
      cancellationToken: CancellationToken? = nil
      ) where T.Update == Update, T.Success == Success

    Parameters

    producerProxy

    to bind to

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

  • bind(_:cancellationToken:) Extension method

    Binds updates to a specified UpdatableProperty

    Declaration

    Swift

    func bind<T: EventDestination>(
      _ eventDestination: T,
      cancellationToken: CancellationToken? = nil
      ) where T.Update == Update, T.Success == Void

    Parameters

    updatableProperty

    to bind to

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

  • Applies transformation to the whole channel. map methods are more convenient if you want to transform updates values only.

    Declaration

    Swift

    func mapEvent<P, S, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ strongContext: C, _ event: Event) throws -> ChannelEvent<P, S>
      ) -> Channel<P, S>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    strongContext

    context restored from weak reference to specified context

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Applies transformation to the whole channel. map methods are more convenient if you want to transform updates values only.

    Declaration

    Swift

    func mapEvent<P, S>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ event: Event) throws -> ChannelEvent<P, S>
      ) -> Channel<P, S>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Applies transformation to update values of the channel. map methods are more convenient if you want to transform both updates and completion

    Declaration

    Swift

    func map<P, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ strongContext: C, _ update: Update) throws -> P
      ) -> Channel<P, Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of the returned channel

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    strongContext

    context restored from weak reference to specified context

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel. map methods are more convenient if you want to transform both updates and completion

    Declaration

    Swift

    func map<P>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ update: Update) throws -> P
      ) -> Channel<P, Success>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<P, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ strongContext: C, _ update: Update) throws -> P?
      ) -> Channel<P, Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Nil returned from transform will not produce update value

    strongContext

    context restored from weak reference to specified context

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<P>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ update: Update) throws -> P?
      ) -> Channel<P, Success>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Nil returned from transform will not produce update value

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<PS: Sequence, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ strongContext: C, _ update: Update) throws -> PS
      ) -> Channel<PS.Iterator.Element, Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Sequence returned from transform will be treated as multiple period values

    strongContext

    context restored from weak reference to specified context

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to update values of the channel.

    Declaration

    Swift

    func flatMap<PS: Sequence>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (_ update: Update) throws -> PS
      ) -> Channel<PS.Iterator.Element, Success>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply. Sequence returned from transform will be treated as multiple period values

    update

    Update to transform

    Return Value

    transformed channel

  • Applies transformation to a completion of EventSource.

    Declaration

    Swift

    func mapCompletion<Transformed, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (C, Fallible<Success>) throws -> Transformed
      ) -> Channel<Update, Transformed>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    strongContext

    context restored from weak reference to specified context

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Applies transformation to a success of EventSource.

    Declaration

    Swift

    func mapSuccess<Transformed, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (C, Success) throws -> Transformed
      ) -> Channel<Update, Transformed>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    strongContext

    context restored from weak reference to specified context

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Applies transformation to a completion of EventSource.

    Declaration

    Swift

    func mapCompletion<Transformed>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (Fallible<Success>) throws -> Transformed
      ) -> Channel<Update, Transformed>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Applies transformation to a success of EventSource.

    Declaration

    Swift

    func mapSuccess<Transformed>(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ transform: @escaping (Success) throws -> Transformed
      ) -> Channel<Update, Transformed>

    Parameters

    executor

    to execute transform on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    transform

    to apply

    value

    ChannelValue to transform. May be either update or completion

    Return Value

    transformed channel

  • Filters update values of the channel

    • context: ExectionContext to apply predicate in
    • executor: override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context
    • cancellationToken: CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive
    • bufferSize: DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel
    • predicate: to apply
    • strongContext: context restored from weak reference to specified context
    • update: Update to transform

    Declaration

    Swift

    func filter<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ predicate: @escaping (_ strongContext: C, _ update: Update) throws -> Bool
      ) -> Channel<Update, Success>

    Return Value

    filtered transform

  • Filters update values of the channel

    • executor: to execute transform on
    • cancellationToken: CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive
    • bufferSize: DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel
    • predicate: to apply
    • update: Update to transform

    Declaration

    Swift

    func filter(
      executor: Executor = .primary,
      pure: Bool = true,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ predicate: @escaping (_ update: Update) throws -> Bool
      ) -> Channel<Update, Success>

    Return Value

    filtered transform

  • unsafelyUnwrapped Extension method

    makes channel of unsafely unwrapped optional Updates

    Declaration

    Swift

    var unsafelyUnwrapped: Channel<Update.Success, Success> { get }
  • unwrapped Extension method

    makes channel of unsafely unwrapped optional Updates

    Declaration

    Swift

    var unwrapped: Channel<Update.Success, Success> { get }
  • Samples the channel with specified channel

    Declaration

    Swift

    func sample<Sampler: EventSource>(
      with sampler: Sampler,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<(Update, Sampler.Update), (Success, Sampler.Success)>

    Parameters

    samplerChannel

    sampler

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    sampled channel

  • Returns channel of the result of calling the given combining closure with each update value of this channel and an accumulating value.

    Declaration

    Swift

    func scan<Result, C: ExecutionContext>(
      _ initialResult: Result,
      context: C,
      executor: Executor? = nil,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ nextPartialResult: @escaping (C, Result, Update) throws -> Result
      ) -> Channel<Result, (Result, Success)>

    Parameters

    initialResult

    the initial accumulating value.

    context

    ExectionContext to call accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    nextPartialResult

    A closure that combines an accumulating value and a update value of the channel into a new accumulating value, to be used in the next call of the nextPartialResult closure or returned to the caller.

    Return Value

    The future tuple of accumulated completion and success of channel.

  • Returns channel of the result of calling the given combining closure with each update value of this channel and an accumulating value.

    Declaration

    Swift

    func scan<Result>(
      _ initialResult: Result,
      executor: Executor = .primary,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      _ nextPartialResult: @escaping (Result, Update) throws -> Result
      ) -> Channel<Result, (Result, Success)>

    Parameters

    initialResult

    the initial accumulating value.

    context

    ExectionContext to call accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    nextPartialResult

    A closure that combines an accumulating value and a update value of the channel into a new accumulating value, to be used in the next call of the nextPartialResult closure or returned to the caller.

    Return Value

    The future tuple of accumulated completion and success of channel.

  • Returns future of the result of calling the given combining closure with each update value of this channel and an accumulating value.

    Declaration

    Swift

    func reduce<Result, C: ExecutionContext>(
      _ initialResult: Result,
      context: C,
      executor: Executor? = nil,
      cancellationToken: CancellationToken? = nil,
      _ nextPartialResult: @escaping (C, Result, Update) throws -> Result
      ) -> Future<(Result, Success)>

    Parameters

    initialResult

    the initial accumulating value.

    context

    ExectionContext to call accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    executor

    to execute call predicate on accumulation closure on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    nextPartialResult

    A closure that combines an accumulating value and a update value of the channel into a new accumulating value, to be used in the next call of the nextPartialResult closure or returned to the caller.

    Return Value

    The future tuple of accumulated completion and success of channel.

  • Returns future of the result of calling the given combining closure with each update value of this channel and an accumulating value.

    Declaration

    Swift

    func reduce<Result>(
      _ initialResult: Result,
      executor: Executor = .primary,
      cancellationToken: CancellationToken? = nil,
      _ nextPartialResult: @escaping (Result, Update) throws -> Result
      ) -> Future<(Result, Success)>

    Parameters

    initialResult

    the initial accumulating value.

    executor

    to execute call accumulation closure on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    nextPartialResult

    A closure that combines an accumulating value and a update value of the channel into a new accumulating value, to be used in the next call of the nextPartialResult closure or returned to the caller.

    Return Value

    The future tuple of accumulated completion and success of channel.

  • Returns future of first update value matching predicate

    Declaration

    Swift

    func first<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      cancellationToken: CancellationToken? = nil,
      `where` predicate: @escaping(C, Update) throws -> Bool
      ) -> Future<Update?>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned future

    predicate

    returns true if update value matches and returned future may be completed with it

    Return Value

    future

  • Returns future of first update value matching predicate

    Declaration

    Swift

    func first(executor: Executor = .immediate,
               cancellationToken: CancellationToken? = nil,
               `where` predicate: @escaping(Update) throws -> Bool
      ) -> Future<Update?>

    Parameters

    executor

    to execute call predicate on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned future

    predicate

    returns true if update value matches and returned future may be completed with it

    Return Value

    future

  • Returns future of last update value matching predicate

    Declaration

    Swift

    func last<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      cancellationToken: CancellationToken? = nil,
      `where` predicate: @escaping(C, Update) throws -> Bool
      ) -> Future<Update?>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    predicate

    returns true if update value matches and returned future may be completed with it

    Return Value

    future

  • Returns future of last update value matching predicate

    Declaration

    Swift

    func last(executor: Executor = .immediate,
              cancellationToken: CancellationToken? = nil,
              `where` predicate: @escaping(Update) throws -> Bool
      ) -> Future<Update?>

    Parameters

    executor

    to execute call predicate on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned future

    predicate

    returns true if update value matches and returned future may be completed with it

    Return Value

    future

  • Checks each update with predicate. Succeeds returned future with true on first found update that matches predicate. Succeeds retured future with false if no matching updates were found

    Declaration

    Swift

    func contains(
      executor: Executor = .primary,
      cancellationToken: CancellationToken? = nil,
      where predicate: @escaping (Update) -> Bool
      ) -> Future<Bool>

    Parameters

    executor

    to execute call predicate on

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned future

    predicate

    returns true if update value matches and returned future may be completed with it

    Return Value

    future

  • Checks each EventSource for a specific falue. Succeeds returned future with true on first found update that is equal to the value. Succeeds retured future with false if no equal updates were found

    Declaration

    Swift

    public func contains(
      _ value: Update,
      cancellationToken: CancellationToken? = nil
      ) -> Future<Bool>

    Parameters

    value

    to check for equality with

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned future

    Return Value

    future

  • Returns channel of distinct update values of original channel. Requires dedicated equality checking closure

    Declaration

    Swift

    public func distinct(
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default,
      isEqual: @escaping (Update, Update) -> Bool
      ) -> Channel<Update, Success>

    Parameters

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    isEqual

    closure that tells if specified values are equal

    Return Value

    channel with distinct update values

  • Returns channel of distinct update values of original channel. Works only for equatable update values [0, 0, 1, 2, 3, 3, 4, 3] => [0, 1, 2, 3, 4, 3]

    Declaration

    Swift

    public func distinct(
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    channel with distinct update values

  • Makes a channel that skips updates

    Declaration

    Swift

    func skip(
      first: Int,
      last: Int,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    first

    number of first updates to skip

    last

    number of last updates to skip

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    channel that skips updates

  • Makes a channel that takes updates specific number of update

    Declaration

    Swift

    func take(
      first: Int,
      last: Int,
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    first

    number of first updates to take

    last

    number of last updates to take

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    channel that takes updates

  • Returns channel of distinct update values of original channel. Works only for collections of equatable values [objectA, objectA, objectB, objectC, objectC, objectA] => [objectA, objectB, objectC, objectA]

    Declaration

    Swift

    public func distinctNSObjects(cancellationToken: CancellationToken? = nil,
                                  bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    channel with distinct update values

  • Returns channel of distinct update values of original channel. Works only for collections of NSObjects values

    [
      [objectA],
      [objectA],
      [objectA, objectB],
      [objectA, objectB, objectC],
      [objectA, objectB, objectC], [objectA]
    ] => [
      [objectA],
      [objectA, objectB],
      [objectA, objectB, objectC], [objectA]
    ]
    

    Declaration

    Swift

    public func distinctCollectionOfNSObjects(
      cancellationToken: CancellationToken? = nil,
      bufferSize: DerivedChannelBufferSize = .default
      ) -> Channel<Update, Success>

    Parameters

    cancellationToken

    CancellationToken to use. Keep default value of the argument unless you need an extended cancellation options of returned primitive

    bufferSize

    DerivedChannelBufferSize of derived channel. Keep default value of the argument unless you need an extended buffering options of returned channel

    Return Value

    channel with distinct update values