Hi, really great article!
Nicola Di Pol
11

Thank you!

Sure, you can use callbacks instead of RxSwift’s Observable, the important thing here is the concept.

As long as you have isolated tasks with single responsibilities, the implementation is up to you.

I’d implement a Task with callbacks like this:

class Task<Input, Output> {
func perform(_ element: Input,
success: (Output) -> Void,
failure: (Error) -> Void) {
fatalError(“This must be implemented in subclasses”)
}
}

I think that Input is not necessary to handle in the callback.

You may want to see my library called FOTask.

I use callbacks there, it’s lightweight and just works! You can also compose more complex tasks with simple tasks and create pipelines using them.

Let me know if you want to discuss something else. 👌