I want to create a sort of queue where I can append work-items which can fail and retry or just succeed and are removed from the queue.
Basically what I am looking for a SomeQueue
which should kind of work like:
let Task = (Data)->Result
let queue = SomeQueue(from: [task1, task2])
.execute()
.retry(3)
.onFailure { failcount++ }
// Some other piece of code that kind of needs to work
Button(action: {
queue.appendWorkItems([Task]())
})
Text(queue.remaining) // way to show unfinished items
I looked into OperationQueue, that kind of looked like it could work. I want it to be as modern and up to date swift as possible and I like the combine publish-subscribe stuff (it has to integrate with swiftUI). This looked like that was a better approach.
Do you have hints / ideas on how I could make this work?