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

Method initAsync

modules/core/LocalizationSystem.js:134–167  ·  view source on GitHub ↗

* initAsync * Called after all core objects have been constructed. * @return {Promise} Promise resolved after the files have been loaded

()

Source from the content-addressed store, hash-verified

132 * @return {Promise} Promise resolved after the files have been loaded
133 */
134 initAsync() {
135 if (this._initPromise) return this._initPromise;
136
137 for (const id of this.dependencies) {
138 if (!this.context.systems[id]) {
139 return Promise.reject(`Cannot init: ${this.id} requires ${id}`);
140 }
141 }
142
143 const assets = this.context.systems.assets;
144 const urlhash = this.context.systems.urlhash;
145 const prerequisites = Promise.all([
146 assets.initAsync(),
147 urlhash.initAsync()
148 ]);
149
150 return this._initPromise = prerequisites
151 .then(() => {
152 return Promise.all([
153 assets.loadAssetAsync('languages'),
154 assets.loadAssetAsync('locales')
155 ]);
156 })
157 .then(results => {
158 this._languages = results[0].languages;
159 this._locales = results[1].locales;
160
161 // Setup event handlers..
162 urlhash.on('hashchange', this._hashchange);
163
164 return this.selectLocaleAsync();
165 })
166 .catch(e => console.error(e)); // eslint-disable-line
167 }
168
169
170 /**

Callers

nothing calls this directly

Calls 4

selectLocaleAsyncMethod · 0.95
loadAssetAsyncMethod · 0.80
errorMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected