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. 👌

    Fernando Martín Ortiz
    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade