-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathim.ts
28 lines (25 loc) · 819 Bytes
/
im.ts
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
import { createStatefulIM } from '@dididc/chat-lib/dist/createIM';
import { store } from './store/index';
import { replaceIMState } from '@dididc/chat-lib/dist/redux';
export const im = createStatefulIM({
apiBase: 'https://poc.saas.bearychat.com/',
haloRegistry: 'http://haloreg.saas.bearychat.com/get_halo_info',
locale: 'zh-CN',
});
im.stateful.subscribe((state, changed) => {
store.dispatch(
replaceIMState(
changed.map((changed) => changed.type),
state
)
);
});
im.stateful.subscribe((_, changedList) => {
if (process.env.NODE_ENV === 'development') {
console.group(`[chat-lib] batched reducers, length ${changedList.length}`);
for (const changed of changedList) {
console.log(`${changed.type[0]}.${changed.type[1]}`, changed);
}
console.groupEnd();
}
});