-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
75 lines (53 loc) · 1.52 KB
/
App.js
File metadata and controls
75 lines (53 loc) · 1.52 KB
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
/*
* 文件名: App.js
* 作者: liushun
* 描述: App 入口
* 修改人:
* 修改时间:
* 修改内容:
* */
import React, {Component} from 'react';
import AppNav from './App/Container/AppContainer'
import { Provider } from 'react-redux'
import configureStore from './App/Redux'
import socket from 'socket.io-client'
import {PersistGate} from 'redux-persist/integration/react'
import {AddRoomMessage, AddRoomUnReadMsg} from './App/Redux/actionCreators'
import Toast from "react-native-root-toast";
import {getFriendList} from "./App/Service/action";
import config from './App/Config'
const io = socket(config.baseURL);
global.io = io
const {store, persistor} = configureStore();
export default class App extends Component<Props> {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<AppNav/>
</PersistGate>
</Provider>
);
}
}
if(__DEV__) {
import('./App/Config/ReactotronConfig.js').then(() => console.log('Reactotron Configured'))
}
io.on('connect', (socket)=>{
console.tron.log('socket connect');
})
io.on('message',(obj)=>{
store.dispatch(AddRoomMessage(obj))
store.dispatch(AddRoomUnReadMsg(obj))
})
io.on('addFriend',()=>{
const user = (store.getState().UserReducer.get('user')).toJS();
store.dispatch(getFriendList(user.id))
})
io.on('disconnect', (socket)=>{
console.tron.log("socket disconnect");
Toast.show('未连接到服务器',{
duration: Toast.durations.SHORT,
position: Toast.positions.TOP
})
})