Rx Java and concurency

54 views
Skip to first unread message

philippe m

unread,
Jun 25, 2020, 9:41:34 AM6/25/20
to RxJava
Hi, i'm an Android developer and just begin with rxJava.

I want to replace my AsyncTask by using RxJava.

With AsyncTask A for example i make multiple network sequential requests and database update in background : (Request 1 response from server Request2 response write1 to database)  and then update mainThread
AsyncTask B is triggered by a firebase message and can too call server and write to database for exemple : (Request 3 response Request 4 response write2 to database) in backgournd and then update mainThread

As aynsctaskA and AsynctaskB can not run concurrently i'm sure that this two tasks  will not overlap i can only have :
(Request 1 response from server Request2 response from server  write1 to database) and then  (Request 3 response Request 4 response write2 to database or
(Request 3 response Request 4 response write2 to database) and then (Request 1 response from server Request2 response from server  write1 to database)

With Rx java i understand how to achieve the same work but how can i be sure that it  will not overlap ? How can i avoid have for example : Request1 response Request3 response Request4 Request2 response write1 write 2 (in background) ?

George Campbell

unread,
Jun 28, 2020, 5:27:53 AM6/28/20
to RxJava
To learn more about Rx on Android look to https://github.com/ReactiveX/RxAndroid/ and probably anything that Jake Wharton is up to.
Reply all
Reply to author
Forward
0 new messages