Giter VIP home page Giter VIP logo

Comments (3)

lmatteis avatar lmatteis commented on July 25, 2024 1

Yeah if you don't need the post info in the stream, then you don't need combine 😃

Anyway in case you need the post this should work:

import sampleCombine from 'xstream/extra/sampleCombine'

const action$ = response$
  .compose(sampleCombine(post$))
  .map(([ response, post ]) => actions.receivePostById(post, response.body))

from redux-cycles.

lmatteis avatar lmatteis commented on July 25, 2024

The problem is with the use of combine: https://github.com/staltz/xstream#-combinestream1-stream2

The second time you call the POST_REQUESTED action from react, it's gonna emit POST_RECEIVED even without a response (because combine uses the latest response).

I think you may need sampleCombine instead (https://github.com/staltz/xstream/blob/master/EXTRA_DOCS.md#-samplecombinestreams) But make sure the source stream is the response.

Hope it makes sense. Let me know if you can figure it out.

from redux-cycles.

dbertella avatar dbertella commented on July 25, 2024

Thank you very much! I'll look into it and let you know!
Edit
I couldn't find the right way to make sampleCombine working instead, but I found out that in my case I don't need the combine at all, at least not for the single post.

const action$ = sources.HTTP
    .select('post')
    .flatten()
    .map(res => actions.receivePostById(res.body.id, res.body));

That makes the trick, but I will have to understand better cycle for more advanced stuff anyway.
Thank you again!

from redux-cycles.

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.