levibostian / Wendy-Android

Build offline first Android mobile apps. Remove loading screens, perform tasks instantly.
https://levibostian.github.io/Wendy-Android/wendy/
MIT License
64 stars 16 forks source link

I should have a timeout for running pending tasks. #18

Closed levibostian closed 6 years ago

levibostian commented 6 years ago

Every instance of PendingTask has a function, runTask(completion: (success: Bool) -> Unit).

It would be a good idea to timeout eventually after starting a task, mark the pending task as complete but unsuccessful, then move on.

levibostian commented 6 years ago

The original reason that I wanted a timeout was because runTask() was asynchronous and in case I forgot to ever call the completion callback, the timeout would keep Wendy going.

Since I switched to synchronous, I decided to skip this for now.

Why:

  1. If you use a database or a HTTP library such as Retrofit, those libraries already have timeouts. Your runTask() should timeout anyway because of that.
  2. I don't like the idea of being able to terminate runTask() if I can help it because I don't want to interrupt a database query half way into execution. Or some other critical task such as that.