-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.tsx
54 lines (45 loc) · 1.45 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
43
44
45
46
47
48
49
50
51
52
53
54
import React, { Component } from 'react'
import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import RootContainer from './RootContainer'
import configureStore from '../Redux/configureStore'
import MainActions from '../Redux/MainRedux'
import Textile, { EventSubscription } from '@textile/react-native-sdk'
import { Linking } from 'react-native'
const { store, persistor } = configureStore()
class App extends Component {
subscriptions: EventSubscription[] = []
render () {
return (
<Provider store={store}>
<PersistGate loading={undefined} persistor={persistor}>
<RootContainer />
</PersistGate>
</Provider>
)
}
handleDeepLink = (event: {url: string}) => {
store.dispatch(MainActions.handleNewDeepLink(event.url))
}
componentDidMount () {
this.subscriptions.push(
Textile.events.addNodeStartedListener(() => {
store.dispatch(MainActions.nodeStarted())
store.dispatch(MainActions.newNodeState('started'))
})
)
this.subscriptions.push(
Textile.events.addNodeStoppedListener(() => {
store.dispatch(MainActions.newNodeState('stopped'))
})
)
Linking.addEventListener('url', this.handleDeepLink)
}
componentWillUnmount () {
for (const subscription of this.subscriptions) {
subscription.cancel()
}
Linking.removeEventListener('url', this.handleDeepLink)
}
}
export default App