yigit / android-priority-jobqueue

A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
3.4k stars 395 forks source link

Allow reactive, asynchronous calls in Job, with call to jobFinished() #402

Open stevep99 opened 7 years ago

stevep99 commented 7 years ago

I am using RxJava to provide reactive, asynchronous access to a database. I would like to be able to call these methods within a Job. The problem is though, because the Job has to succeed or fail within the onRun() method's body, there is no way to perform any asynchronous operations. I realize I could use toBlocking() on my rx calls, but that seems a little unsatisfactory.

I have read this ticket #230 about asynchronous jobs, but I still think asynchronous support would be an excellent improvement, being a good way to properly support RxJava.

If you take a look at the Android JobScheduler, it supports the ability to run job synchronously or asynchronously. In the case of asynchronously, it is the developer's responsibility to call jobFinished() to indicate the job completed. There is an example here.

This approach gives more flexibility and would be great if android-priority-jobqueue could support it too!