-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
107 lines (103 loc) · 2.39 KB
/
Copy pathindex.js
File metadata and controls
107 lines (103 loc) · 2.39 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
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
import React from 'react'
import { AppRegistry } from 'react-native'
import { Provider } from 'react-redux'
import createStore from './src/store'
import Router from './src'
import moment from 'moment' // temporary for example use
const start = Date.now()
// fetch initial data dependencies and render
Promise.all([
// GET DATA FROM FILE
Promise.resolve({})
// load external data
// or initial state
])
.then((result) => {
let initialState // or populate from loaded data
if (result.length) {
initialState = result[0]
} else {
initialState = {}
}
return createStore(initialState)
})
.then(store => Promise.all([
store,
// dispatch initial actions on store
// store.dispatch( some action )
store.dispatch({
type: 'CARD_CREATE',
card: {
id: 1,
name: 'card_1',
amount: 500,
currency: 'USD',
createdAt: new Date(),
updatedAt: new Date()
}
}),
store.dispatch({
type: 'CARD_CREATE',
card: {
id: 2,
name: 'card_2',
amount: 12000,
currency: 'UAH',
createdAt: new Date(),
updatedAt: new Date()
}
}),
store.dispatch({
type: 'ACTIVITY_CREATE',
date: moment(new Date()).format('DD/MM/YYYY'),
activity: {
id: 1,
cardId: 2,
name: 'Activity_1',
amount: -550,
createdAt: new Date(),
updatedAt: new Date()
}
}),
store.dispatch({
type: 'ACTIVITY_CREATE',
date: moment(new Date()).format('DD/MM/YYYY'),
activity: {
id: 2,
cardId: 2,
name: 'Activity_2',
amount: 320,
createdAt: new Date(),
updatedAt: new Date()
}
}),
store.dispatch({
type: 'ACTIVITY_EDIT',
date: moment(new Date()).format('DD/MM/YYYY'),
activity: {
id: 2,
cardId: 2,
name: 'Renamed activity',
updatedAt: new Date()
}
}),
store.dispatch({
type: 'CARD_EDIT',
card: {
id: 1,
name: 'Edited_card',
updatedAt: new Date()
}
})
]))
.then(([store]) => {
const App = () =>
<Provider store={store}>
<Router />
</Provider>
AppRegistry.registerComponent('CoinFlow', () => App)
}).then(() => {
if (__DEV__) {
console.log(`initial render after ${(Date.now() - start).toFixed(3)}ms`)
}
})