-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
42 lines (36 loc) · 1.03 KB
/
App.tsx
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
import { Button, StyleSheet, View } from 'react-native';
import { RNEventSource } from './backend/libs/RNEventSource';
import ApiService from './backend/services';
export default function App() {
return (
<View style={styles.container}>
<Button
title="인사하기"
onPress={() => {
ApiService.createMessage('안녕하세요').then((result) => {
const es = new RNEventSource(result.id);
es.addEventListener('open', () => {
console.log('open');
});
es.addEventListener('message', (data) => {
console.log('message', data);
if (data === '[DONE]') {
ApiService.getMessages().then((result) => {
console.log('result', result);
});
}
});
});
}}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});