CoalescingAction
public class CoalescingAction<Output, Error> : ActionProtocol where Error : Error
Similar to Action
, except if the action is already executing, subsequent apply()
call will not fail,
and will be completed with the same output when the initial executing action completes.
Disposing any of the SignalProducer
returned by ‘apply()` will cancel the action.
-
Declaration
Swift
public typealias Input = Void
-
Whether the action is currently executing.
Declaration
Swift
public var isExecuting: Property<Bool> { get }
-
Whether the action is currently executing.
Declaration
Swift
public let isEnabled: Property<Bool>
-
A signal of all events generated from all units of work of the
Action
.In other words, this sends every
Event
from every unit of work that theAction
executes.Declaration
Swift
public var events: Signal<Signal<Output, Error>.Event, NoError> { get }
-
A signal of all values generated from all units of work of the
Action
.In other words, this sends every value from every unit of work that the
Action
executes.Declaration
Swift
public var values: Signal<Output, NoError> { get }
-
A signal of all errors generated from all units of work of the
Action
.In other words, this sends every error from every unit of work that the
Action
executes.Declaration
Swift
public var errors: Signal<Error, NoError> { get }
-
The lifetime of the
Action
.Declaration
Swift
public var lifetime: Lifetime { get }
-
Initializes a
CoalescingAction
.When the
Action
is asked to start the execution with an input value, a unit of work — represented by aSignalProducer
— would be created by invokingexecute
with the input value.Declaration
Swift
public init(execute: @escaping () -> SignalProducer<Output, Error>)
Parameters
execute
A closure that produces a unit of work, as
SignalProducer
, to be executed by theAction
. -
Create a
SignalProducer
that would attempt to create and start a unit of work of theAction
. TheSignalProducer
would forward only events generated by the unit of work it created.Declaration
Swift
public func apply(_ input: Input) -> SignalProducer<Output, Error>
Parameters
input
Must be
()
.Return Value
A producer that forwards events generated by its started unit of work. If the action was already executing, it will create a
SignalProducer
that will forward the events of the initially createdSignalProducer
.