Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BenchmarkEvents.js « util « benchmarks « wwwroot « Microsoft.AspNetCore.Blazor.E2EPerformance « wasm - github.com/mono/illinker-test-assets.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ebfa7bda04878b268123f2b78bdc08ea74eb05d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const pendingCallbacksByEventName = {};

// Returns a promise that resolves the next time we receive the specified event
export function receiveEvent(name) {
  let capturedResolver;
  const resultPromise = new Promise(resolve => {
    capturedResolver = resolve;
  });

  pendingCallbacksByEventName[name] = pendingCallbacksByEventName[name] || [];
  pendingCallbacksByEventName[name].push(capturedResolver);

  return resultPromise;
}

// Listen for messages forwarded from the child frame
window.receiveBenchmarkEvent = function (name) {
  const callbacks = pendingCallbacksByEventName[name];
  delete pendingCallbacksByEventName[name];
  callbacks && callbacks.forEach(callback => callback());
}