Tabnine Logo For Javascript
pubsub-js
Code IndexAdd Tabnine to your IDE (free)

How to use pubsub-js

Best JavaScript code snippets using pubsub-js(Showing top 14 results out of 315)

origin: eMarek/React-examples

React.createClass({
  handleClick: function() {
    PubSub.publish('PRODUCT_CLICKED', this.props.name);
  },
  render: function() {
    return (
      <div onClick={this.handleClick}>{this.props.name}</div>
    );
  }
})
origin: john-doherty/raspberry-pi-mjpeg-server

// 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);
    }
  });
});
origin: eMarek/React-examples

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>
    );
  }
})
origin: eMarek/React-examples

handleLogout: function(e) {
  e.preventDefault;
  PubSub.publish('SESSION_CARE', false);
},
handleProfile: function(e) {
  e.preventDefault;
  PubSub.publish('POPUP_OPEN', {
    type: "custom",
    template: "ChangePassword"
origin: john-doherty/raspberry-pi-mjpeg-server

var subscriber_token = PubSub.subscribe('MJPEG', function(msg, data) {
  PubSub.unsubscribe(subscriber_token);
  res.end();
});
origin: eMarek/React-examples

    });
  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,
origin: eMarek/React-examples

      });
      if (rsp.status === "ok") {
        PubSub.publish('GATHERINGS_REFRESH');
        _.delay(function() {
          PubSub.publish('POPUP_CLOSE', 'GatheringCreate');
        }, 500);
},
handleCancel: function(e) {
  PubSub.publish('POPUP_CLOSE', 'GatheringCreate');
},
render: function() {        
origin: eMarek/React-examples

  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",
origin: eMarek/React-examples

if (rsp.status === "ok") {
  _.delay(function(session) {
    PubSub.publish('SESSION_CARE', session);
  }.bind(this), 500, rsp.session);
origin: eMarek/React-examples

    });
  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) {
origin: eMarek/React-examples

  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) {
origin: eMarek/React-examples

        });
        _.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() {
origin: eMarek/React-examples

      if (rsp.status === "ok") {
        _.delay(function() {
          PubSub.publish('POPUP_CLOSE', 'ChangePassword');
        }, 1000);
},
handleCancel: function(e) {
  PubSub.publish('POPUP_CLOSE', 'ChangePassword');
},
render: function() {        
origin: eMarek/React-examples

        });
        _.delay(function() {
          PubSub.publish('POPUP_CLOSE', 'FillTheName');
        }, 3500);
      } else {
    message: "You will be logged out in few seconds."
  });
  PubSub.publish('SESSION_CARE', false);
  _.delay(function() {
    PubSub.publish('POPUP_CLOSE', 'FillTheName');
  }, 1500);
},
pubsub-js(npm)

Most used pubsub-js functions

  • Base.publish
  • Base.subscribe
  • Base.unsubscribe

Popular in JavaScript

  • glob
    a little globber
  • redis
    Redis client library
  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • chalk
    Terminal string styling done right
  • mime-types
    The ultimate javascript content-type utility.
  • winston
    A logger for just about everything.
  • minimist
    parse argument options
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • debug
    small debugging utility
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now