Last active
October 22, 2016 13:25
-
-
Save bnhansn/94aaca47a1e2572b410840100b4948ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function connectToChannel(socket, roomId) { | |
| return (dispatch) => { | |
| if (!socket) { return false; } | |
| const channel = socket.channel(`rooms:${roomId}`); | |
| channel.join().receive('ok', (response) => { | |
| dispatch({ type: 'ROOM_CONNECTED_TO_CHANNEL', response, channel }); | |
| }); | |
| return false; | |
| }; | |
| } | |
| export function leaveChannel(channel) { | |
| return (dispatch) => { | |
| if (channel) { | |
| channel.leave(); | |
| } | |
| dispatch({ type: 'USER_LEFT_ROOM' }); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment