-
Notifications
You must be signed in to change notification settings - Fork 328
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
adding Reflux.connect #75
Conversation
var Status = React.createClass({ | ||
mixins: [Reflux.connect(statusStore,"currentStatus")], | ||
render: function() { | ||
// render specifics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more clear about it, comment should say that you can use this.state.currentStatus
in the render method. In tandem with what the documentation says above the example, since that's where the state variable (given by the key) will practically be used.
@krawaller could you fix the merge conflict? |
Nod, will be home in a few hours! Good point about the code example, will fix that too at the same time. |
Cool. Will be much appreciated. Hopefully we can make a release for 0.1.8 like... soonish. :-) |
Conflict fixed, examples updated. |
Cool. Thanks! |
After several iterations, I think I've arrived at a good convenience method for the common use case when you want to make a React component set its state to whatever a listenable returns.
This pull request exposes
Reflux.connect(listenable,[stateKey])
, intented to be used as a mixin much likeReflux.listenTo
. IfstateKey
is supplied then it will dosetState({<stateKey>:data})
, otherwise justsetState(data)
.Here's the
Reflux.listenTo
example from the README:...which using
Reflux.connect
instead can be reduced to this:Isn't it beatiful? Absolutely nothing boilerplaty whatsoever! :)
I found in my
Reflux
app I could almost always useReflux.connect
as it was only in very rare cases that I needed to do some special logic.