Replace addListener method with multiple bindings, fix for #503 504

This commit is contained in:
Legend Tang 2015-03-06 03:45:58 +08:00
parent b903dd4e4a
commit 36db55f662
2 changed files with 25 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -65,15 +65,24 @@ var FlowTable = React.createClass({
},
componentWillMount: function () {
if (this.props.view) {
this.props.view.addListener("add update remove recalculate", this.onChange);
this.props.view.addListener("add", this.onChange);
this.props.view.addListener("update", this.onChange);
this.props.view.addListener("remove", this.onChange);
this.props.view.addListener("recalculate", this.onChange);
}
},
componentWillReceiveProps: function (nextProps) {
if (nextProps.view !== this.props.view) {
if (this.props.view) {
this.props.view.removeListener("add update remove recalculate");
this.props.view.removeListener("add");
this.props.view.removeListener("update");
this.props.view.removeListener("remove");
this.props.view.removeListener("recalculate");
}
nextProps.view.addListener("add update remove recalculate", this.onChange);
nextProps.props.view.addListener("add", this.onChange);
nextProps.props.view.addListener("update", this.onChange);
nextProps.props.view.addListener("remove", this.onChange);
nextProps.props.view.addListener("recalculate", this.onChange);
}
},
getDefaultProps: function () {