* initAsync * Called after all core objects have been constructed. * @return {Promise} Promise resolved when this component has completed initialization
()
| 68 | * @return {Promise} Promise resolved when this component has completed initialization |
| 69 | */ |
| 70 | initAsync() { |
| 71 | if (this._initPromise) return this._initPromise; |
| 72 | |
| 73 | for (const id of this.dependencies) { |
| 74 | if (!this.context.systems[id]) { |
| 75 | return Promise.reject(`Cannot init: ${this.id} requires ${id}`); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | const context = this.context; |
| 80 | const assets = context.systems.assets; |
| 81 | const gfx = context.systems.gfx; |
| 82 | const l10n = context.systems.l10n; |
| 83 | const urlhash = context.systems.urlhash; |
| 84 | |
| 85 | // Many UI components require l10n and gfx (for scene/layers) |
| 86 | const prerequisites = Promise.all([ |
| 87 | assets.initAsync(), |
| 88 | l10n.initAsync(), |
| 89 | gfx.initAsync(), |
| 90 | urlhash.initAsync(), |
| 91 | ]); |
| 92 | |
| 93 | return this._initPromise = prerequisites |
| 94 | .then(() => { |
| 95 | window.addEventListener('resize', this.resize); |
| 96 | |
| 97 | this._checkEnvironment(); // are we in a dev or staging environment? |
| 98 | |
| 99 | // Create UI components |
| 100 | this.ApiStatus = new UiApiStatus(context); |
| 101 | this.AuthModal = uiLoading(context).blocking(true).message(l10n.t('loading_auth')); |
| 102 | this.Defs = new UiDefs(context); |
| 103 | this.EditMenu = uiEditMenu(context); |
| 104 | this.MapRouletteMenu = uiMapRouletteMenu(context); |
| 105 | this.Flash = uiFlash(context); |
| 106 | this.Fullscreen = new UiFullscreen(context); |
| 107 | this.MapFooter = new UiMapFooter(context); |
| 108 | this.MapToolbar = new UiMapToolbar(context); |
| 109 | this.Overmap = new UiOvermap(context); |
| 110 | this.Shortcuts = new UiShortcuts(context); |
| 111 | this.Sidebar = new UiSidebar(context); |
| 112 | |
| 113 | // These components live below in the tree, but we will hold a reference |
| 114 | // to them here in the UiSystem, so that other code can find them easily. |
| 115 | this.InfoCards = this.Overmap.InfoCards; |
| 116 | this.Minimap = this.Overmap.Minimap; |
| 117 | this.PhotoViewer = this.Overmap.PhotoViewer; |
| 118 | this.Spector = this.Overmap.Spector; |
| 119 | |
| 120 | // Setup Event listeners.. |
| 121 | l10n.on('localechange', () => { |
| 122 | if (this._started) { |
| 123 | this.render(); |
| 124 | } |
| 125 | }); |
| 126 | |
| 127 | const osm = context.services.osm; |
nothing calls this directly
no test coverage detected