-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explore mixins, etc. for transitive state #84
Comments
For transitive data, would it be very much against the standard of Flux, return a promise in the component? Sample: var actions = {
searchUsers: function(params) {
var self = this;
return WebAPI.searchUsers(params)
.success(function(data) {
self.dispatch(constants.SEARCH_USERS_SUCCESS, data);
}).error( function(data) {
self.dispatch(constants.SEARCH_USERS_ERROR, data);
});
}
};
React.createClass({
handleClick: function() {
this.setState({loading: true});
this.getFlux().actions.searchUsers(...).always(function() { this.setState({loading: false}); };
}
});
// Store dont need to know about loading data, and dont need to re-render everthing just because that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
E.g. a form submits via an action, then the action errors. We want to display the error to the user, but when the form goes away we want to stop storing the error (or, at minimum, ensure it doesn't show the next time we display the form).
We can clear the error with an action in
componentWillUnmount
, which requires more boilerplate than we'd like. Maybe there's a way to generalize this transitive state problem to make dealing with these kinds of things easier.See also https://gist.github.com/thomasboyt/5a2fda0db3af7d93c8b6 by @thomasboyt
The text was updated successfully, but these errors were encountered: