How to use the pubsub-js.subscribe function in pubsub-js

To help you get started, we’ve selected a few pubsub-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnosullivan / hippodrome / controllers / dispatcher.js View on Github external
};
    var sessionPrestartConfirm_func = function (event_name, data) {
      self.sessions[self.playerToSession[data['rand_user']]].sessionPrestartConfirm(data);
    };
    var sendFrame_func = function (event_name, data) {
      self.sessions[self.playerToSession[data['rand_user']]].sendFrame(data);
    };
    var completedRound_func = function (event_name, data) {
      self.sessions[self.playerToSession[data['rand_user']]].completedRound(data);
    };
    var terminateSession_func = function (event_name, data) {
      console.log("Terminate Session: ", data['session_id']);
      delete self.sessions[data['session_id']];
    };
    // sets the pubsub handlers for the dispatcher
    this.readyForSession_pubsub = PubSub.subscribe('readyForSession', readyForSession_func);
    this.readyPlayer_pubsub = PubSub.subscribe('playerReady', readyPlayer_func);
    this.readyNotPlayer_pubsub = PubSub.subscribe('playerNotReady', readyNotPlayerr_func);
    this.sessionPrestartConfirm_pubsub = PubSub.subscribe('sessionPrestartConfirm', sessionPrestartConfirm_func);
    this.sendFrame_pubsub = PubSub.subscribe('sendFrame', sendFrame_func);
    this.completedRound_pubsub = PubSub.subscribe('completedRound', completedRound_func);
    this.exitSessionQuene_pubsub = PubSub.subscribe('exitSessionQuene', exitSessionQuene_func);
    this.confirmedConnection_pubsub = PubSub.subscribe('confirmedSession', confirmed_connection_func);
    this.leaveSession_pubsub = PubSub.subscribe('leaveSession', leaveSessionn_func);
    this.disconnectUser_pubsub = PubSub.subscribe('disconnectUser', disconnectUser_func);
    this.terminateSession_pubsub = PubSub.subscribe('terminateSession', terminateSession_func);
  }
github gabrielflorit / livecoding / src / js / components / Livecoding.jsx View on Github external
componentWillMount: function() {

		var self = this;

		// Setup all the subscriptions.
		PubSub.subscribe(Editor.topics().ContentChange, self.handleContentChange);
		PubSub.subscribe(MenuBar.topics().ModeChange, self.handleModeChange);
		PubSub.subscribe(MenuBar.topics().ItemClick, self.handleMenuItemClick);
		PubSub.subscribe(GitHub.topics().Token, self.handleGatekeeperToken);
		PubSub.subscribe(Avatar.topics().LoginClick, self.handleLoginClick);

		// If there's a gist id in the url, retrieve the gist.
		var match = location.href.match(/[a-z\d]+$/);
		if (match) {
			GitHub.readGist(this.getToken(), match[0])
				.then(function(gist) {

					// Instruct Output to render all code.
					self.makeOutputRenderAllCode.pop();
					self.makeOutputRenderAllCode.push(true);

					// Extract code contents and selected mode.
					var data = GitHub.convertGistToLivecodingData(gist);
github Happy0 / ssb-chess / ctrl / userViewingGame.js View on Github external
module.exports = () => {
  let currentGameId = null;

  function lookingAtGame(gameId) {
    currentGameId = gameId;
  }

  function notLookingAtGame() {
    currentGameId = null;
  }

  PubSub.subscribe('viewing_game', (msg, data) => {
    lookingAtGame(data.gameId);
  });

  PubSub.subscribe('exited_game', () => {
    notLookingAtGame();
  });

  return {
    getCurrentGame: () => currentGameId,
  };
};
github AdChain / AdChainRegistryDapp / src / components / single_domain / DomainVoteTokenDistribution.js View on Github external
componentDidMount () {
    this._isMounted = true
    this.subEvent = PubSub.subscribe('DomainVoteTokenDistribution.getPoll', this.getPoll)
    if (this.props.domainData) {
      this.getPoll()
    }
  }
github Happy0 / ssb-chess / ctrl / userViewingGame.js View on Github external
module.exports = () => {
  let currentGameId = null;

  function lookingAtGame(gameId) {
    currentGameId = gameId;
  }

  function notLookingAtGame() {
    currentGameId = null;
  }

  PubSub.subscribe('viewing_game', (msg, data) => {
    lookingAtGame(data.gameId);
  });

  PubSub.subscribe('exited_game', () => {
    notLookingAtGame();
  });

  return {
    getCurrentGame: () => currentGameId,
  };
};
github AdChain / AdChainRegistryDapp / src / components / registry_guide / RegistryWalkthrough.js View on Github external
pubsubSubscription () {
    this.startWalkthroughEvent = PubSub.subscribe('RegistryWalkthrough.startJoyride', this.startJoyride)
    this.handleWalkthroughCallbackEvent = PubSub.subscribe('RegistryWalkthrough.handleJoyride', this.handleJoyrideCallback)
    this.resumeWalkthroughEvent = PubSub.subscribe('RegistryWalkthrough.resumeJoyride', this.resumeJoyride)
    this.toggleOverlayEvent = PubSub.subscribe('RegistryWalkthrough.toggleOverlay', this.toggleOverlay)
    this.confirmWalkthroughEvent = PubSub.subscribe('RegistryWalkthrough.confirmWalkthrough', this.confirmWalkthrough)
    this.resetStepsEvent = PubSub.subscribe('RegistryWalkthrough.resetSteps', this.resetSteps)
  }
}
github AdChain / AdChainRegistryDapp / src / components / registry_guide / RegistryGuideModal.js View on Github external
pubsubSubscription () {
    this.startRegistryWalkthroughEvent = PubSub.subscribe('RegistryGuideModal.startRegistryWalkthrough', this.startRegistryWalkthrough)
    this.viewGuideEvent = PubSub.subscribe('RegistryGuideModal.show', this.show)
    this.redirectEvent = PubSub.subscribe('RegistryGuideModal.redirect', this.redirect)
    this.returnToMenuEvent = PubSub.subscribe('RegistryGuideModal.returnToMenu', this.returnToMenu)
  }
}
github igorski / efflux-tracker / src / js / controller / DialogWindowController.js View on Github external
        ].forEach(( msg ) => Pubsub.subscribe( msg, handleBroadcast ));
    }
github Lobos / react-ui / src / Modal.js View on Github external
componentDidMount () {
    PubSub.subscribe(ADD_MODAL, this.addModal.bind(this));

    PubSub.subscribe(REMOVE_MODAL, this.removeModal.bind(this));

    PubSub.subscribe(CLICKAWAY, () => {
      let props = modals[modals.length - 1];
      if (props.clickaway) {
        PubSub.publish(REMOVE_MODAL);
      }
    });
  }
github xiaolin3303 / react-music-player / app / final / Root.js View on Github external
return music !== item;
				})
			});
		});
		PubSub.subscribe('PLAY_NEXT', () => {
			this.playNext();
		});
		PubSub.subscribe('PLAY_PREV', () => {
			this.playNext('prev');
		});
		let repeatList = [
			'cycle',
			'once',
			'random'
		];
		PubSub.subscribe('CHANAGE_REPEAT', () => {
			let index = repeatList.indexOf(this.state.repeatType);
			index = (index + 1) % repeatList.length;
			this.setState({
				repeatType: repeatList[index]
			});
		});
	},
	componentWillUnmount() {