Skip to content

Instantly share code, notes, and snippets.

@JacobKnaack JacobKnaack/socket.js Secret
Created Jun 14, 2019

Embed
What would you like to do?
Cosmic Messenger socket config module
import openSocket from 'socket.io-client';
export const socket = openSocket(__API_ORIGIN__);
const subscribeToMessages = (callback) => {
socket.on('message', message => callback(null, message));
socket.emit('subscribeToMessages');
}
const subscribeToRegister = (callback) => {
socket.on('register', user => callback(null, user));
socket.emit('subscribeToRegister');
}
const subscribeToLogout = (callback) => {
socket.on('logout', user => callback(null, user));
socket.emit('subscribeToLogout');
}
export default {
subscribeToMessages,
subscribeToRegister,
subscribeToLogout,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.