Last active
August 29, 2015 14:13
-
-
Save benekastah/ea77ef8920268bea8580 to your computer and use it in GitHub Desktop.
React Model Logic Brainstorm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChartEditor = React.createClass({ | |
datasetDidChange: function () { | |
this.setState({ | |
datasets: chartioStore.get('datasets') | |
}); | |
} | |
}); | |
DatasetModel = React.createClass({ | |
components: [ChartEditor], | |
addAttribute: function (attr) { | |
var chartioStore = store.getStore(); | |
this.addAttribute(attr); | |
chartioStore.update('datasets', this.data); | |
this.didChange(); | |
}, | |
/** | |
* Other methods that manipulate the data somehow... | |
*/ | |
didChange: function () { | |
this.components.forEach(function (component) { | |
component.datasetDidChange(this); | |
}); | |
} | |
}); | |
DatasetComponent = React.createClass({ | |
model: DatasetModel, | |
addAttribute: function () { | |
var attr = {...}; | |
this.model.addAttribute(attr); | |
}, | |
render: function () { | |
return (<button onClick={this.addAttribute}>Add attr</button>); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment