React.createClass({ handleClick: function() { PubSub.publish('PRODUCT_CLICKED', this.props.name); }, render: function() { return ( <div onClick={this.handleClick}>{this.props.name}</div> ); } })
// hook file change events and send the modified image to the browser watcher.on('change', function(file) { //console.log('change >>> ', file); fs.readFile(file, function(err, imageData) { if (!err) { PubSub.publish('MJPEG', imageData); } else { console.log(err); } }); });
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> ); } })
var subscriber_token = PubSub.subscribe('MJPEG', function(msg, data) { PubSub.unsubscribe(subscriber_token); res.end(); });
}); this.token_GATHERING_SELECT = PubSub.subscribe('GATHERING_SELECT', this.gatheringSelect); }, componentWillUnmount: function() { PubSub.unsubscribe(this.token_GATHERING_SELECT); }, gatheringSelect: function(topic, gathering) { }, handleBack: function() { this.token_BACKBUTTON_CLICK = PubSub.publish('BACKBUTTON_CLICK'); this.setState({ gathering: false,
this.token_POPUP_CLOSE = PubSub.subscribe('POPUP_CLOSE', this.popupClose); }, componentWillUnmount: function() { message: '' }); PubSub.unsubscribe(this.token_POPUP_CLOSE); }, componentDidMount: function() { }); if (rsp.status === "error" && rsp.error === "doublecheck") { PubSub.publish('POPUP_OPEN', { type: "custom", template: "RegistrationDoubleCheck",
if (rsp.status === "ok") { _.delay(function(session) { PubSub.publish('SESSION_CARE', session); }.bind(this), 500, rsp.session);
}); this.token_SESSION_CARE = PubSub.subscribe('SESSION_CARE', this.sessionCare); this.token_GATHERING_SELECT = PubSub.subscribe('GATHERING_SELECT', this.gatheringSelect); this.token_BACKBUTTON_CLICK = PubSub.subscribe('BACKBUTTON_CLICK', this.backButtonClick); this.token_POPUP_OPEN = PubSub.subscribe('POPUP_OPEN', this.popupOpen); this.token_POPUP_CLOSE = PubSub.subscribe('POPUP_CLOSE', this.popupClose); }, 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) {
this.token_GATHERINGS_REFRESH = PubSub.subscribe('GATHERINGS_REFRESH', function(topic) { this.refreshGatherings(); }.bind(this)); }, componentWillUnmount: function() { PubSub.unsubscribe(this.token_GATHERINGS_REFRESH); }, refreshGatherings: function() { handleGatheringStart: function(e) { e.preventDefault; PubSub.publish('POPUP_OPEN', { type: "custom", template: "GatheringCreate" }, handleGatheringOpen: function(gathering) { PubSub.publish('GATHERING_SELECT', gathering); }, renderGathering: function(gathering) {
}); _.delay(function() { PubSub.publish('POPUP_CLOSE', 'RegistationDoubleCheck'); }.bind(this), 3000); } else { }, handleCancel: function(e) { PubSub.publish('POPUP_CLOSE', 'RegistationDoubleCheck'); }, handleClose: function(e) { PubSub.publish('POPUP_CLOSE', 'RegistationDoubleCheck'); }, renderButtons: function() {