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
next
function supplied to each and everyCallback
instanceDeclaration
Swift
typealias Next = (Error?) -> Void
-
Initializes a new
SequenceProcessor
with 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
Callback
parsers that will have a chance to modify or swap out the next executingCallback
in the listDeclaration
Swift
var listeners: [SequenceProcessor<Context>.PreFireListener]
-
A sequence that will be started after all callbacks including
postSequenceCallback
are 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
item
to this Checkout process at the end of the listDeclaration
Swift
func append(_ item: SequenceProcessor<Context>.Callback)
-
Returns index of item with specified
itemType
in this Checkout process ornil
if it’s not foundDeclaration
Swift
func index(of itemType: SequenceProcessor<Context>.Callback.Type) -> Int?
-
Inserts
item
to this Checkout process at the specifiedindex
Declaration
Swift
func insert(_ item: SequenceProcessor<Context>.Callback, at index: Int)
-
Removes item from this Checkout process as the specified
index
and returns the removed itemDeclaration
Swift
func remove(at index: Int) -> SequenceProcessor<Context>.Callback