React.createClass({ getInitialState: function() { return { selection: 'none' }; }, componentWillMount: function() { // when React renders me, I subscribe to the topic 'PRODUCT_CLICKED' // and .subscribe returns a unique token necessary to unsubscribe this.pubsub_token = PubSub.subscribe('PRODUCT_CLICKED', function(topic, product) { // update my selection when there is a message this.setState({ selection: product }); }.bind(this)); }, componentWillUnmount: function() { // React removed me from the DOM, I have to unsubscribe from the PubSub using my token PubSub.unsubscribe(this.pubsub_token); }, render: function() { return ( <div>You have selected the product: {this.state.selection}</div> ); } })
PubSub.unsubscribe(subscriber_token); res.end(); });
}, componentWillUnmount: function() { PubSub.unsubscribe(this.token_GATHERING_SELECT); }, gatheringSelect: function(topic, gathering) {
}, componentWillUnmount: function() { PubSub.unsubscribe(this.token_SESSION_CARE); PubSub.unsubscribe(this.token_GATHERING_SELECT); PubSub.unsubscribe(this.token_BACKBUTTON_CLICK); PubSub.unsubscribe(this.token_POPUP_OPEN); PubSub.unsubscribe(this.token_POPUP_CLOSE); }, sessionCare: function(topic, session) {
message: '' }); PubSub.unsubscribe(this.token_POPUP_CLOSE); }, componentDidMount: function() {
}, componentWillUnmount: function() { PubSub.unsubscribe(this.token_GATHERINGS_REFRESH); }, refreshGatherings: function() {