MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / tryGet

Function tryGet

front_end/core/common/ResolverBase.ts:41–53  ·  view source on GitHub ↗

* Resolve the `id`. Returns the object immediately if it can be resolved, * and otherwise waits for the object to appear and calls `callback` once * it is resolved.

(id: Id, callback: (t: T) => void)

Source from the content-addressed store, hash-verified

39 * it is resolved.
40 */
41 tryGet(id: Id, callback: (t: T) => void): T|null {
42 const obj = this.getForId(id);
43 if (!obj) {
44 const swallowTheError = (): void => {};
45 void this.getOrCreatePromise(id).catch(swallowTheError).then(obj => {
46 if (obj) {
47 callback(obj);
48 }
49 });
50 return null;
51 }
52 return obj;
53 }
54
55 /**
56 * Aborts all waiting and rejects all unresolved promises.

Callers

nothing calls this directly

Calls 2

callbackFunction · 0.70
getForIdMethod · 0.45

Tested by

no test coverage detected