12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- const NativeCommandsSender = require('./adapters/NativeCommandsSender');
- const NativeEventsReceiver = require('./adapters/NativeEventsReceiver');
- const UniqueIdProvider = require('./adapters/UniqueIdProvider');
- const Store = require('./containers/Store');
- const ContainerRegistry = require('./containers/ContainerRegistry');
- const Commands = require('./commands/Commands');
- const LayoutTreeParser = require('./commands/LayoutTreeParser');
- const LayoutTreeCrawler = require('./commands/LayoutTreeCrawler');
- const PrivateEventsListener = require('./events/PrivateEventsListener');
- const PublicEventsRegistry = require('./events/PublicEventsRegistry');
-
- class Navigation {
- constructor() {
- this.store = new Store();
- this.nativeEventsReceiver = new NativeEventsReceiver();
- this.uniqueIdProvider = new UniqueIdProvider();
- this.containerRegistry = new ContainerRegistry(this.store);
- this.layoutTreeParser = new LayoutTreeParser();
- this.layoutTreeCrawler = new LayoutTreeCrawler(this.uniqueIdProvider, this.store);
- this.nativeCommandsSender = new NativeCommandsSender();
- this.commands = new Commands(this.nativeCommandsSender, this.layoutTreeParser, this.layoutTreeCrawler);
- this.publicEventsRegistry = new PublicEventsRegistry(this.nativeEventsReceiver);
- this.privateEventsListener = new PrivateEventsListener(this.nativeEventsReceiver, this.store);
- this.privateEventsListener.listenAndHandlePrivateEvents();
- }
-
- registerContainer(containerName, getContainerFunc) {
- this.containerRegistry.registerContainer(containerName, getContainerFunc);
- }
-
- setRoot(params) {
- return this.commands.setRoot(params);
- }
-
- setOptions(containerId, options) {
- this.commands.setOptions(containerId, options);
- }
-
- showModal(params) {
- return this.commands.showModal(params);
- }
-
- dismissModal(containerId) {
- return this.commands.dismissModal(containerId);
- }
-
- dismissAllModals() {
- return this.commands.dismissAllModals();
- }
-
- push(onContainerId, params) {
- return this.commands.push(onContainerId, params);
- }
-
- pop(containerId) {
- return this.commands.pop(containerId);
- }
-
- popTo(containerId) {
- return this.commands.popTo(containerId);
- }
-
- popToRoot(containerId) {
- return this.commands.popToRoot(containerId);
- }
-
- switchToTab(onContainerId, tabIndex) {
- return this.commands.switchToTab(onContainerId, tabIndex);
- }
-
- events() {
- return this.publicEventsRegistry;
- }
-
- showOverlay(type, options) {
- return this.commands.showOverlay(type, options);
- }
- }
-
- const singleton = new Navigation();
- module.exports = singleton;
|