ios – The best way to use Mix to ship and obtain in an async course of?

I’ve a case in mine that I need to filter an array in several class, and the filtering course of is in async-await course of.
Right here is my code and outline of my case:
class ProcessorClass {
var objectA = CurrentValueSubject<[ObjectA]?, By no means>(nil)
var filteredObjectA = [ObjectA]()
func asyncProcessFunc() async {
// ... async-await course of to get the array of ObjectA
let objectAs = await getObjectAs()
objectA.ship(objectAs)
// ... async-await course of to course of the filtered ObjectA
await processFilteredObject(object: filteredObjectA)
}
func getObjectAs() async -> [ObjectA] {
// ... do course of to get ObjectA array
}
func processFilteredObject(object: [ObjectA]) async {
// ... do course of to filtered ObjectA array
}
}
class ReceiverClass {
var subscriber = Cancelable()
func receiverFunc(processor: ProcessorClass) {
processor.objectA
.sink { objects in
if objects != nil {
processor.filteredObjectA.append(objects!.final!) // ... Do filtering course of, for instance: I might wish to course of the final object solely
}
}.retailer(in: subscriber)
}
}
My asyncProcessFunc
of ProcessorClass
is doing a course of to get the array of ObjectA
, and I might wish to move it to my ReceiverClass
to be filtered which ObjectA
that I might wish to course of within the ProcessorClass
.
Presently I used mix framework to repair it.
However I ponder if there’s another methods to unravel my case.
And I apprehensive if there will likely be bizarre bugs in future, as a result of the asyncProcessFunc()
of ProcessorClass
is operating asynchronously and have to attend a course of to be accomplished earlier than executing different course of.
Any suggestion can be very appreciated!
Thanks upfront.
Credit: www.ismmailgsm.com