|
@@ -1,30 +1,32 @@
|
1
|
|
-const NativeCommandsSender = require('./adapters/NativeCommandsSender');
|
2
|
|
-const NativeEventsReceiver = require('./adapters/NativeEventsReceiver');
|
3
|
|
-const UniqueIdProvider = require('./adapters/UniqueIdProvider');
|
4
|
|
-const Store = require('./components/Store');
|
5
|
|
-const ComponentRegistry = require('./components/ComponentRegistry');
|
6
|
|
-const Commands = require('./commands/Commands');
|
7
|
|
-const LayoutTreeParser = require('./commands/LayoutTreeParser');
|
8
|
|
-const LayoutTreeCrawler = require('./commands/LayoutTreeCrawler');
|
9
|
|
-const PrivateEventsListener = require('./events/PrivateEventsListener');
|
10
|
|
-const PublicEventsRegistry = require('./events/PublicEventsRegistry');
|
11
|
|
-
|
|
1
|
+import { NativeCommandsSender } from './adapters/NativeCommandsSender';
|
|
2
|
+import { NativeEventsReceiver } from './adapters/NativeEventsReceiver';
|
|
3
|
+import { UniqueIdProvider } from './adapters/UniqueIdProvider';
|
|
4
|
+import { Store } from './components/Store';
|
|
5
|
+import { ComponentRegistry } from './components/ComponentRegistry';
|
|
6
|
+import { Commands } from './commands/Commands';
|
|
7
|
+import { LayoutTreeParser } from './commands/LayoutTreeParser';
|
|
8
|
+import { LayoutTreeCrawler } from './commands/LayoutTreeCrawler';
|
|
9
|
+import { PrivateEventsListener } from './events/PrivateEventsListener';
|
|
10
|
+import { PublicEventsRegistry } from './events/PublicEventsRegistry';
|
|
11
|
+import { ComponentProvider } from 'react-native';
|
12
|
12
|
import { Element } from './adapters/Element';
|
13
|
13
|
|
14
|
14
|
class Navigation {
|
|
15
|
+ public readonly Element = Element;
|
|
16
|
+
|
|
17
|
+ private readonly store = new Store();
|
|
18
|
+ private readonly nativeEventsReceiver = new NativeEventsReceiver();
|
|
19
|
+ private readonly uniqueIdProvider = new UniqueIdProvider();
|
|
20
|
+ private readonly componentRegistry = new ComponentRegistry(this.store);
|
|
21
|
+ private readonly layoutTreeParser = new LayoutTreeParser();
|
|
22
|
+ private readonly layoutTreeCrawler = new LayoutTreeCrawler(this.uniqueIdProvider, this.store);
|
|
23
|
+ private readonly nativeCommandsSender = new NativeCommandsSender();
|
|
24
|
+ private readonly commands = new Commands(this.nativeCommandsSender, this.layoutTreeParser, this.layoutTreeCrawler);
|
|
25
|
+ private readonly publicEventsRegistry = new PublicEventsRegistry(this.nativeEventsReceiver);
|
|
26
|
+ private readonly privateEventsListener = new PrivateEventsListener(this.nativeEventsReceiver, this.store);
|
|
27
|
+
|
15
|
28
|
constructor() {
|
16
|
|
- this.store = new Store();
|
17
|
|
- this.nativeEventsReceiver = new NativeEventsReceiver();
|
18
|
|
- this.uniqueIdProvider = new UniqueIdProvider();
|
19
|
|
- this.componentRegistry = new ComponentRegistry(this.store);
|
20
|
|
- this.layoutTreeParser = new LayoutTreeParser();
|
21
|
|
- this.layoutTreeCrawler = new LayoutTreeCrawler(this.uniqueIdProvider, this.store);
|
22
|
|
- this.nativeCommandsSender = new NativeCommandsSender();
|
23
|
|
- this.commands = new Commands(this.nativeCommandsSender, this.layoutTreeParser, this.layoutTreeCrawler);
|
24
|
|
- this.publicEventsRegistry = new PublicEventsRegistry(this.nativeEventsReceiver);
|
25
|
|
- this.privateEventsListener = new PrivateEventsListener(this.nativeEventsReceiver, this.store);
|
26
|
29
|
this.privateEventsListener.listenAndHandlePrivateEvents();
|
27
|
|
- this.Element = Element;
|
28
|
30
|
}
|
29
|
31
|
|
30
|
32
|
/**
|
|
@@ -32,7 +34,7 @@ class Navigation {
|
32
|
34
|
* @param {string} componentName Unique component name
|
33
|
35
|
* @param {function} getComponentClassFunc generator function, typically `() => require('./myComponent')`
|
34
|
36
|
*/
|
35
|
|
- registerComponent(componentName, getComponentClassFunc) {
|
|
37
|
+ registerComponent(componentName: string, getComponentClassFunc: ComponentProvider) {
|
36
|
38
|
this.componentRegistry.registerComponent(componentName, getComponentClassFunc);
|
37
|
39
|
}
|
38
|
40
|
|