MCPcopy Create free account
hub / github.com/facebook/Rapid / initAsync

Method initAsync

modules/core/PresetSystem.js:67–112  ·  view source on GitHub ↗

* initAsync * Called after all core objects have been constructed. * @return {Promise} Promise resolved when this component has completed initialization

()

Source from the content-addressed store, hash-verified

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 /**

Callers

nothing calls this directly

Calls 11

mergeMethod · 0.95
areaKeysMethod · 0.95
pointTagsMethod · 0.95
vertexTagsMethod · 0.95
osmSetAreaKeysFunction · 0.90
osmSetPointTagsFunction · 0.90
osmSetVertexTagsFunction · 0.90
getMethod · 0.80
filterMethod · 0.80
splitMethod · 0.80
loadAssetAsyncMethod · 0.80

Tested by

no test coverage detected