GithubHelp home page GithubHelp logo

Comments (7)

DarthMike avatar DarthMike commented on June 27, 2024

I've come up with a solution that makes it work. But I'm not sure it's elegant or correct. Some part of the code:

let stream = api.search(barcode)
                |> map { $0.searchableName }
                |> concat(Stream.never()) // Between stream boundaries
                |> flatMap { name in
                    return bgg.searchGames(name, type: .Games, match: .Loose)
                } |> take(1)

So basically I insert a never stream between stream boundaries, to keep the next stream alive.

from reactkit.

inamiy avatar inamiy commented on June 27, 2024

Thanks for pointing out this issue.
Current flatMap() has a different implementation compared to other Rx frameworks,
and I should say this is a bug.
Your code will be a good workaround, and I will try fixing this issue soon.

from reactkit.

DarthMike avatar DarthMike commented on June 27, 2024

Thanks @inamiy .
I've got another question regarding streams which are bound. What is the behaviour of error propagation?

let stream = api.search(barcode) 
                |> flatMap {
                    return anotherStream(...)  // This stream fails via reject()
                }

I have two streams concatenated via flatmap, and then the second is rejected, but stream failure or completion callback is not called. Any clues what I might be missing?

from reactkit.

inamiy avatar inamiy commented on June 27, 2024

@DarthMike
In your case, if anotherStream(...) gets rejected, stream will also get rejected.
You can register callbacks likestream.failure(callback) or stream.then(callback) to check its being called, but doesn't it work for you?

from reactkit.

DarthMike avatar DarthMike commented on June 27, 2024

@inamiy I subscribe via:
stream.react {
...
}.failure {
...
}
But don't receive callbacks for failure

from reactkit.

DarthMike avatar DarthMike commented on June 27, 2024

@inamiy Let me elaborate: It may be a side effect of my workaround with Stream.never().
The actual stream composition is:

 let stream = api.search(barcode)
                |> map { $0.searchableName }
                |> concat(Stream.never())
                |> flatMap { name in
                    return anotherStream(...)
                }

I've tried pointing my code to the FlattenStyle branch, and refactoring it to look like:

 let stream = api.search(barcode)
                |> map { $0.searchableName }
                |> flatMap(.Concat) { name in
                    return anotherStream(...)
                }

Then works properly with react + failure.

from reactkit.

inamiy avatar inamiy commented on June 27, 2024

@DarthMike
Hm, actually, I don't think concat(Stream.never()) in your first code will affect the error propagation to downstream, so it should work just similar to second code...

But anyway!
Important part is your second code, and if that's working correctly,
I think we are now able to merge #44.

Thanks for checking this issue 😊

from reactkit.

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.