-
Notifications
You must be signed in to change notification settings - Fork 18
/
tradingModule.ts
72 lines (65 loc) · 2.92 KB
/
tradingModule.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
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
import * as uuid from 'uuid';
import * as Rx from 'rx';
import {Container, EspDiConsts} from 'esp-js-di';
import {
ModuleBase,
StateService,
ComponentFactoryBase,
SystemContainerConst,
PrerequisiteRegister,
Logger,
espModule
} from 'esp-js-ui';
import {TradingModuleContainerConst} from './tradingModuleContainerConst';
import {CashTileComponentFactory} from './cash-tile/cashTileComponentFactory';
import {BlotterComponentFactory} from './blotter/blotterComponentFactory';
import {BlotterModel} from './blotter/models/blotterModel';
import {TradingModuleDefaultStateProvider} from './tradingModuleDefaultStateProvider';
let _log = Logger.create('TradingModule');
@espModule('trading-module', 'Trading Module')
export class TradingModule extends ModuleBase {
_componentFactoryGroupId: string;
_tradingModuleDefaultStateProvider = new TradingModuleDefaultStateProvider();
constructor(container: Container, stateService: StateService) {
super(container, stateService);
this._componentFactoryGroupId = uuid.v4();
}
protected getDefaultStateProvider() {
return this._tradingModuleDefaultStateProvider;
}
configureContainer() {
_log.group('Configuring container');
_log.debug(`Registering ${TradingModuleContainerConst.cashTileComponentFactory}`);
this.container
.register(TradingModuleContainerConst.cashTileComponentFactory, CashTileComponentFactory)
.inject(EspDiConsts.owningContainer, SystemContainerConst.router)
.singleton()
.inGroup(this._componentFactoryGroupId);
_log.debug(`Registering ${TradingModuleContainerConst.blotterComponentFactory}`);
this.container
.register(TradingModuleContainerConst.blotterComponentFactory, BlotterComponentFactory)
.inject(EspDiConsts.owningContainer, SystemContainerConst.router)
.singleton()
.inGroup(this._componentFactoryGroupId);
_log.debug(`Registering ${TradingModuleContainerConst.blotterModel}`);
this.container
.register(TradingModuleContainerConst.blotterModel, BlotterModel)
.inject(SystemContainerConst.router, SystemContainerConst.region_manager)
.singletonPerContainer();
_log.groupEnd();
}
getComponentsFactories(): Array<ComponentFactoryBase<any>> {
return this.container.resolveGroup(this._componentFactoryGroupId);
}
registerPrerequisites(register: PrerequisiteRegister): void {
_log.groupCollapsed('Registering Prerequisites');
_log.debug(`Registering 1`);
register.registerStream(
Rx.Observable.timer(2000).take(1).concat(Rx.Observable.throw(new Error('Load error'))),
'Loading Module That Fails'
);
_log.debug(`Registering 2`);
register.registerStream(Rx.Observable.timer(2000).take(1), 'Loading Referential Data');
_log.groupEnd();
}
}