android - How to control the order of rxjava multi-thread concurrency
怪我咯
怪我咯 2017-05-16 13:33:18
0
3
772

The requirement is to get the chat list from the server, and then traverse to get the chat records. I used Observable.from(conversations) and then inserted the conversation into the local database, filtered it to get the required data, and finally updated the view
I saw it One afternoon, there are so many keywords related to
SerializedSubject (I can’t use SerializedSubject.from(conversations), and converting to Observable also reports an error)
trampoline (Put the task in the queue of the current thread, and wait for the current task to be executed. After that, continue to execute the tasks in the queue)
concatEager (What is the difference between this operator and concatMap http://blog.csdn.net/kisty_ya... But there are no examples of use and I don’t understand)
Just now At first, the next step is processed in onNext, and then I use flatMap to process it, but it ends when the launch is completed, without waiting for onNext to finish executing, and I feel that doOnNext and flatMap are the same. I hope you can give me some advice. I feel like a headless fly. Same, can you write down the idea in pseudo code? Thank you

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
左手右手慢动作

If you want to filter, you should use the Filter operator

给我你的怀抱

Using this operator concatMap can ensure that the order of thread execution will not be disordered!

过去多啦不再A梦
    Obserable.fromCallable()
             .filter()
             .subscribe(io)
             .obserableOn(ui)
             .subscribe(action)
             
如果是需要将过滤的数据重新保存
    Obserable data = Obserable.fromCallable()
             .filter()
             .subscribe(io)
             .share();
   data.obserableon(io)
       .subscribe(数据库)
   data.obserableOn(ui)
       .subscribe(更新)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template