Code Monkey home page Code Monkey logo

Comments (5)

vanniktech avatar vanniktech commented on June 24, 2024 1

I don't quite understand the problem.

RxRule is having a Scheduler that will run. The essential part is that subscribe is called eagerly. Which is asserted with assertEmpty() & assertThat(subscribeCounter.get()).isEqualTo(2) // We want to subscribe immediately.

from rxriddles.

vanniktech avatar vanniktech commented on June 24, 2024

I'm going to close this for now as I don't see a reason to change this. If you feel otherwise feel free to message me again.

from rxriddles.

lwasylkowski avatar lwasylkowski commented on June 24, 2024

@vanniktech I'll message here since I had similar thoughts when doing riddle no 6.

The point is, the solution proposed:

Spoiler
object Riddle6Solution {
  fun solve(first: Single<Int>, second: Single<Int>)
      = Single.zip(first, second, BiFunction<Int, Int, Pair<Int, Int>> { t1, t2 -> t1 to t2 })
}

does not introduce any parallelism. The comment states:

Execute both [first] and [second] Single's in parallel and provide both results as a pair.

but the solution does not execute any arbitrary pair of singles in parallel. On the contrary, as long as first and single doesn't specify schedulers, the solution works sequentially. The solution is appropriate only for this specific use case (implemented in tests), where singles already work on separate scheduler(s).

For actual educational value I'd expect that the provided singles don't have schedulers applied. I believe this is one of the things that are surprising for the beginners: in order to have the two streams work in parallel, we need to move them off the main thread manually, while the riddle suggests otherwise

from rxriddles.

vanniktech avatar vanniktech commented on June 24, 2024

Yup, that's right! Should we add a sentence to the documentation that we can assume that each Single has already a Scheduler applied? Or how do you want to proceed?

from rxriddles.

lwasyl avatar lwasyl commented on June 24, 2024

@vanniktech took me a while to find time for this, here is my suggestion. I believe not providing a scheduler and not changing the comment is the way to go for this to still be a riddle ;) Let me know what you think

from rxriddles.

Related Issues (8)

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.