Skip to content

Instantly share code, notes, and snippets.

@benekastah
Last active August 29, 2015 14:13
Show Gist options
  • Save benekastah/ea77ef8920268bea8580 to your computer and use it in GitHub Desktop.
Save benekastah/ea77ef8920268bea8580 to your computer and use it in GitHub Desktop.
React Model Logic Brainstorm
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