cyclejs-community / redux-cycles

Bring functional reactive programming to Redux using Cycle.js
MIT License
745 stars 30 forks source link

Request for a complex real world example #39

Open jintoppy opened 7 years ago

jintoppy commented 7 years ago

Hi,

I got really interested in redux-cycles. But, I am new to streams. Is it possible to add a an example project where there will be multiple async actions in a queue?

For eg. upon selecting an item from the list, a popup displayed which shows different kinds of data about the item, in which each data is the result of an async action.

Thanks much.

jintoppy commented 7 years ago

I have created a sample react application in redux and redux-thunk. In this application, there will be a list of users. When you click on a user, there will be one async action to get user details which contains the countryId of the user. Using that information, next async action is triggered to get all states.

How can we improve this scenario with redux-cycles?

You can see the code here and demo here.

The part in which I am really interested is given below.

let promise = this.props.getUserDetails(this.props.selectedUser.id);    
promise.then(() => {
    this.props.getStates(this.props.selectedUser.country);
});

I am not liking this way of coding, because, now there is a dependency and the order is important in this approach.

How this can be re-written using redux-cycles?

Thanks much.

aaronmcadam commented 7 years ago

@jintoppy I've been looking at https://github.com/cyclejs-community/awesome-cyclejs#example-applications. Did you find any complex example apps? I'm looking for one that uses HTTP progress.