Total Complexity | 0 |
Complexity/F | 0 |
Lines of Code | 32 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import Registry from '@enbock/application-router/Registry'; |
||
2 | import Router, {PageData} from '@enbock/application-router/Router'; |
||
3 | import DataStorage from '@enbock/simple-storage/DataStorage'; |
||
4 | import ListenerAdapter from '@enbock/state-value-observer/ListenerAdapter'; |
||
5 | import ValueObserver from '@enbock/state-value-observer/ValueObserver'; |
||
6 | |||
7 | class Container { |
||
8 | adapter: ListenerAdapter<PageData | null>; |
||
9 | observer: ValueObserver<PageData | null>; |
||
10 | router: Router; |
||
11 | registry: Registry; |
||
12 | storage: DataStorage; |
||
13 | |||
14 | constructor() { |
||
15 | 1 | this.storage = new DataStorage('router', window.localStorage); |
|
16 | 1 | this.adapter = new ListenerAdapter<PageData | null>(); |
|
17 | 1 | this.observer = new ValueObserver<PageData | null>( |
|
18 | this.storage.loadData('lastPage', null), |
||
19 | this.storage.attach<PageData | null>('lastPage', this.adapter) |
||
20 | ); |
||
21 | |||
22 | 1 | this.registry = new Registry(this.observer); |
|
23 | 1 | this.registry.attachAdapter(this.adapter); |
|
24 | |||
25 | 1 | this.router = new Router(this.observer, history); |
|
26 | 1 | this.router.attachTo(window); |
|
27 | 1 | this.router.initialize(); |
|
28 | } |
||
29 | } |
||
30 | |||
31 | export default new Container(); |
||
32 |