Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. export function connectToChannel(socket, roomId) {
  2. return (dispatch) => {
  3. if (!socket) { return false; }
  4. const channel = socket.channel(`rooms:${roomId}`);
  5.  
  6. channel.join().receive('ok', (response) => {
  7. dispatch({ type: 'ROOM_CONNECTED_TO_CHANNEL', response, channel });
  8. });
  9.  
  10. return false;
  11. };
  12. }
  13.  
  14. export function leaveChannel(channel) {
  15. return (dispatch) => {
  16. if (channel) {
  17. channel.leave();
  18. }
  19. dispatch({ type: 'USER_LEFT_ROOM' });
  20. };
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement