/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v19.1.1
scripts/jest/patchMessageChannel.js
30 строк
908 B
Josh Story
[Flight][Fizz] schedule work async (#29551)
06 июн 2024, 20:07
Не верифицирован
06 июн 2024, 20:07
b526a0a
Код
Авторство
О чём код?
'use strict'; export function patchMessageChannel(Scheduler) { global.MessageChannel = class { constructor() { const port1 = { onmesssage: () => {}, }; this.port1 = port1; this.port2 = { postMessage(msg) { if (Scheduler) { Scheduler.unstable_scheduleCallback( Scheduler.unstable_NormalPriority, () => { port1.onmessage(msg); } ); } else { throw new Error( 'MessageChannel patch was used without providing a Scheduler implementation. This is useful for tests that require this class to exist but are not actually utilizing the MessageChannel class. However it appears some test is trying to use this class so you should pass a Scheduler implemenation to the patch method' ); } }, }; } }; }