var React = require('react'); var StrategyList = require('./StrategyList'); var StrategyForm = require('./StrategyForm'); var StrategyStore = require('../../stores/StrategyStore'); var StrategyActions = require('../../stores/StrategyActions'); var StrategiesComponent = React.createClass({ getInitialState: function() { return { createView: false, strategies: StrategyStore.getStrategies() }; }, onStoreChange: function() { this.setState({ strategies: StrategyStore.getStrategies() }); }, componentDidMount: function() { this.unsubscribe = StrategyStore.listen(this.onStoreChange); }, componentWillUnmount: function() { this.unsubscribe(); }, onNewStrategy: function() { this.setState({createView: true}); }, onCancelNewStrategy: function() { this.setState({createView: false}); }, onSave: function(strategy) { StrategyActions.create.triggerPromise(strategy) .then(this.onCancelNewStrategy); }, onRemove: function(strategy) { StrategyActions.remove.triggerPromise(strategy); }, render: function() { return (