GithubHelp home page GithubHelp logo

Comments (4)

sergdort avatar sergdort commented on May 22, 2024 1

In my opinion subscribeOn does not make any difference here as URLSession uses it's own internal queue to process response, and creating network request is not that performance impact operation ¯_(ツ)_/¯

from cleanarchitecturerxswift.

sergdort avatar sergdort commented on May 22, 2024

Hi, @lizhiquan! Glad that it helps :)

With subscribeOn you can specify on which scheduler (thread, queue) you want subscription to happened. And sometimes it's very important, for example in case of core data all operations need to be performed inside of the context.execute { } block. That's why I've used ContextScheduler there. In case of Realm I did not want all operations to be performed on the main thread as well

With observeOn you can specify on which scheduler (thread, queue) you want to observe values emitted by the observable sequence. And and it's very important when it comes to UI bindings because all UI related updates must be on the Main queue

from cleanarchitecturerxswift.

lizhiquan avatar lizhiquan commented on May 22, 2024

Hi, @sergdort!
I understand the difference between two operators, but I wonder why don't you use subscribeOn in your Network requests. As I know, the code after observeOn will run on the scheduler you specified.
So in this case, network request will run on current scheduler (maybe main scheduler) and the mapper to json will run on concurrent scheduler. If we use subscribeOn, we will make both api request and json mapper stuff all run on concurrent scheduler, which is more appropriate.

from cleanarchitecturerxswift.

lizhiquan avatar lizhiquan commented on May 22, 2024

Thank you :)

from cleanarchitecturerxswift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.