Comments (3)
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.
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.
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)
- Package dependencies HOT 2
- Example failing tests HOT 1
- Travis for `example` dir HOT 8
- Slides
- State should be passed with the action HOT 19
- WebpackBin cannot resolve redux-cycles HOT 1
- Hot reloading HOT 4
- TypeScript Type Declarations HOT 3
- Request for a complex real world example HOT 2
- Typescript definitions are not added to the build HOT 6
- relative preset "es2015" not found with create-react-native-app HOT 1
- scheduleMicrotask is not a function HOT 4
- Is this project still active/maintained? HOT 2
- Simplest "PING/PONG" example in README.md has no 'rootReducer'
- What are the $s in variable names? HOT 1
- New test helpers? HOT 2
- Keep getting generic type parameter errors during compile
- Support multiple stream libraries HOT 6
- Linter HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-cycles.