SequenceProcessor
class SequenceProcessor<Context>
extension SequenceProcessor : CheckoutProcess where Context == State
The SequenceProcessor is designed to take a list of callback instances
and execute the first one while providing it the ability to execute the
next item in the list. This style of sequencing allows for truly
asynchronous execution with each closure either passing the Next
instance off to another function or class to be executed later or to
be ignored if logic in that step indicates that progress should not
continue.
Each closure must execute the Next closure for the chain to continue.
Passing an error to the closure will cause execution to halt.
-
A convenient alias for the callback.
Declaration
Swift
typealias Callback = Step<Context> -
The
nextfunction supplied to each and everyCallbackinstanceDeclaration
Swift
typealias Next = (Error?) -> Void -
Initializes a new
SequenceProcessorwith the supplied list of items to process. Each callback is called in sequence.Declaration
Swift
init(_ items: [SequenceProcessor<Context>.Callback] = [], queue: DispatchQueue? = nil) -
A sequential list of
Callbackparsers that will have a chance to modify or swap out the next executingCallbackin the listDeclaration
Swift
var listeners: [SequenceProcessor<Context>.PreFireListener] -
A sequence that will be started after all callbacks including
postSequenceCallbackare executedDeclaration
Swift
var nextSequence: SequenceProcessor<Context>? -
A queue to execute all callbacks and listeners on. If nil then current queue will be used.
Declaration
Swift
let queue: DispatchQueue?
-
Adds
itemto this Checkout process at the end of the listDeclaration
Swift
func append(_ item: SequenceProcessor<Context>.Callback) -
Returns index of item with specified
itemTypein this Checkout process ornilif it’s not foundDeclaration
Swift
func index(of itemType: SequenceProcessor<Context>.Callback.Type) -> Int? -
Inserts
itemto this Checkout process at the specifiedindexDeclaration
Swift
func insert(_ item: SequenceProcessor<Context>.Callback, at index: Int) -
Removes item from this Checkout process as the specified
indexand returns the removed itemDeclaration
Swift
func remove(at index: Int) -> SequenceProcessor<Context>.Callback
View on GitHub
Install in Dash
SequenceProcessor Class Reference