Skip to content

Commit

Permalink
Remove wrapper function around StoreWatchMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Tilley committed May 18, 2014
1 parent f6b9298 commit 7015951
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions lib/store_watch_mixin.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
module.exports = function(React) {
return function() {
var storeNames = Array.prototype.slice.call(arguments);
return {
componentWillMount: function() {
var flux = this.props.flux || this.context.flux;
_.each(storeNames, function(store) {
flux.store(store).on("change", this._setStateFromFlux)
}, this);
},
module.exports = function() {
var storeNames = Array.prototype.slice.call(arguments);
return {
componentWillMount: function() {
var flux = this.props.flux || this.context.flux;
_.each(storeNames, function(store) {
flux.store(store).on("change", this._setStateFromFlux)
}, this);
},

componentWillUnmount: function() {
var flux = this.props.flux || this.context.flux;
_.each(storeNames, function(store) {
flux.store(store).off("change", this._setStateFromFlux)
}, this);
},
componentWillUnmount: function() {
var flux = this.props.flux || this.context.flux;
_.each(storeNames, function(store) {
flux.store(store).off("change", this._setStateFromFlux)
}, this);
},

_setStateFromFlux: function() {
this.setState(this.getStateFromFlux());
},
_setStateFromFlux: function() {
this.setState(this.getStateFromFlux());
},

getInitialState: function() {
return this.getStateFromFlux();
}
getInitialState: function() {
return this.getStateFromFlux();
}
};
}
};

0 comments on commit 7015951

Please sign in to comment.