search

Home  >  Q&A  >  body text

android - How to control the order of rxjava multi-thread concurrency

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

怪我咯怪我咯2742 days ago738

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 13:35:18

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

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:35:18

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

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:35:18

        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(更新)

    reply
    0
  • Cancelreply