-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.es6
51 lines (44 loc) · 1.42 KB
/
app.es6
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
import ScreenActionCreators from 'actions/ScreenActionCreators';
import Screen from 'components/Screen';
import conf from 'conf';
import AppDispatcher from 'dispatcher/AppDispatcher';
import AppInput from 'input/AppInput';
import EventManager from 'lib/EventManager';
import SingletonMixin from 'lib/mixins/SingletonMixin';
import DialogStore from 'stores/DialogStore';
import GameStore from 'stores/GameStore';
import ScreenStore from 'stores/ScreenStore';
export default class App {
/*
* Initialize unique instances in consideration of the order
*/
static initializeInstances() {
[
() => EventManager.getInstance(),
() => AppDispatcher.getInstance(),
() => DialogStore.getInstance(),
() => GameStore.getInstance(),
() => ScreenStore.getInstance(),
() => AppInput.getInstance()
].forEach(task => task());
}
static purgeInstances() {
[
() => Screen.clearInstance(),
() => AppInput.clearInstance(),
() => ScreenStore.clearInstance(),
() => DialogStore.clearInstance(),
() => GameStore.clearInstance(),
() => AppDispatcher.clearInstance(),
() => EventManager.clearInstance()
].forEach(task => task());
}
constructor() {
this.constructor.initializeInstances();
}
start() {
Screen.getInstance({ componentMode: conf.componentMode });
ScreenActionCreators.changePage('welcome');
}
}
Object.assign(App, SingletonMixin);