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

Method loadAssetAsync

modules/core/AssetSystem.js:254–285  ·  view source on GitHub ↗

* loadAssetAsync * Returns a Promise to fetch the data identified by the key. * @param {string} key - identifier for the data, should be found in the asset map. * @return {Promise} Promise resolved with the data

(key)

Source from the content-addressed store, hash-verified

252 * @return {Promise} Promise resolved with the data
253 */
254 loadAssetAsync(key) {
255 if (this._cache[key]) {
256 return Promise.resolve(this._cache[key]);
257 }
258
259 let url;
260 try {
261 url = this.getAssetURL(key);
262 } catch (err) {
263 return Promise.reject(err.message);
264 }
265
266 let loadPromise = this._inflight[url];
267 if (!loadPromise) {
268 this._inflight[url] = loadPromise = fetch(url)
269 .then(utilFetchResponse)
270 .then(result => {
271 delete this._inflight[url];
272 if (!result) {
273 throw new Error(`No data loaded for "${key}"`);
274 }
275 this._cache[key] = result;
276 return result;
277 })
278 .catch(err => {
279 delete this._inflight[url];
280 throw err;
281 });
282 }
283
284 return loadPromise;
285 }
286
287}

Callers 15

initAsyncMethod · 0.80
initAsyncMethod · 0.80
initAsyncMethod · 0.80
initAsyncMethod · 0.80
_loadStringsAsyncMethod · 0.80
initWaybackAsyncMethod · 0.80
_loadNsiPresetsAsyncMethod · 0.80
_loadNsiDataAsyncMethod · 0.80
startAsyncMethod · 0.80
startAsyncMethod · 0.80
validationOutdatedTagsFunction · 0.80
showMethod · 0.80

Calls 1

getAssetURLMethod · 0.95

Tested by

no test coverage detected