* initAsync * Called after all core objects have been constructed. * @return {Promise} Promise resolved when this component has completed initialization
()
| 65 | * @return {Promise} Promise resolved when this component has completed initialization |
| 66 | */ |
| 67 | initAsync() { |
| 68 | if (this._initPromise) return this._initPromise; |
| 69 | |
| 70 | for (const id of this.dependencies) { |
| 71 | if (!this.context.systems[id]) { |
| 72 | return Promise.reject(`Cannot init: ${this.id} requires ${id}`); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | const context = this.context; |
| 77 | const assets = context.systems.assets; |
| 78 | const locations = context.systems.locations; |
| 79 | const urlhash = context.systems.urlhash; |
| 80 | |
| 81 | const prerequisites = Promise.all([ |
| 82 | assets.initAsync(), |
| 83 | locations.initAsync(), |
| 84 | urlhash.initAsync() |
| 85 | ]); |
| 86 | |
| 87 | return this._initPromise = prerequisites |
| 88 | .then(() => { |
| 89 | // If we received a subset of addable presetIDs specified in the url hash, save them. |
| 90 | const presetIDs = urlhash.initialHashParams.get('presets'); |
| 91 | if (presetIDs) { |
| 92 | const arr = presetIDs.split(',').map(s => s.trim()).filter(Boolean); |
| 93 | this.addablePresetIDs = new Set(arr); |
| 94 | } |
| 95 | |
| 96 | // Fetch the preset data |
| 97 | return Promise.all([ |
| 98 | assets.loadAssetAsync('tagging_preset_categories'), |
| 99 | assets.loadAssetAsync('tagging_preset_defaults'), |
| 100 | assets.loadAssetAsync('tagging_preset_presets'), |
| 101 | assets.loadAssetAsync('tagging_preset_fields'), |
| 102 | assets.loadAssetAsync('tagging_preset_overrides') // customizations to merge in after the id-tagging-schema |
| 103 | ]); |
| 104 | }) |
| 105 | .then(vals => { |
| 106 | this.merge({ categories: vals[0], defaults: vals[1], presets: vals[2], fields: vals[3] }); |
| 107 | this.merge(vals[4]); |
| 108 | osmSetAreaKeys(this.areaKeys()); |
| 109 | osmSetPointTags(this.pointTags()); |
| 110 | osmSetVertexTags(this.vertexTags()); |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /** |
nothing calls this directly
no test coverage detected