This repository has been archived by the owner on Dec 27, 2021. It is now read-only.
forked from yandex-shri-minsk-2018/deo-iuvante
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
112 lines (106 loc) · 3.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import reducer from './reducers';
import './index.css';
import App from './containers/App';
import './cable';
import './apiV2';
const store = createStore(
reducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
applyMiddleware(thunkMiddleware),
);
ReactDOM.render(
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>,
document.getElementById('root'),
);
// import api from './api';
//
// Example of usage API
//
// (async () => {
// //
// // Events
// //
//
// // On status of user is changed
// await api.onUserChangeStatus((result) => {
// console.log('Change status: ', result);
// });
//
// // On user is joined to room
// await api.onUserJoinedRoom((result) => {
// console.log('User joined room: ', result);
// });
//
// // On user is joined to room
// await api.onUserLeavedRoom((result) => {
// console.log('User leaved room: ', result);
// });
//
// // On user is joined to room
// await api.onMessage((result) => {
// console.log('New message: ', result);
// });
//
// //
// // Actions
// //
//
// // Fetch current user
// let user = await api.getCurrentUser();
// console.log('Current user', user);
//
// // Fetch user information
// console.log('User information', await api.getUser(user._id));
//
// // Get users
// let users = await api.getUsers({limit: 100});
// console.log('List of all users', users);
//
// // We have more users
// if (users.next) {
// console.log('More users', await api.getUsers(users.next));
// }
//
// // Create room
// try {
// console.log('New room created', await api.createRoom({name: 'Test'}));
// } catch (err) {
// console.log(err.message);
// }
//
// // Get list of all rooms
// let rooms = await api.getRooms();
// console.log('All rooms', rooms);
//
// console.log('Get room info', await api.getRoom(rooms.items[0]._id));
//
// // Try to join to first room in list
// console.log('Join current user to room', await api.currentUserJoinRoom(rooms.items[0]._id));
//
// // Try to join to first room in list
// console.log('Join some user to room', await api.userJoinRoom(users.items[0]._id, rooms.items[0]._id));
//
// // Get current user list of rooms
// console.log('Current user rooms: ', await api.getCurrentUserRooms());
//
// // Send message to room
// console.log('Send message', await api.sendMessage(rooms.items[0]._id, `Test message ${Date.now()}`));
//
// // Send message to room
// console.log('Room messages', await api.getRoomMessages(rooms.items[0]._id));
//
// // Leave room
// console.log('Leave current user to room', await api.currentUserLeaveRoom(rooms.items[0]._id));
//
// console.log(api);
// })();