src/Router/Container.ts
last analyzed

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 32
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 32
ccs 8
cts 8
cp 1
c 0
b 0
f 0
wmc 0
mnd 0
bc 0
fnc 0
bpm 0
cpm 0
noi 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