Files
callstack__react-native-tes…/src/flushMicroTasks.js
T

23 lines
552 B
JavaScript
Raw Normal View History

// @flow
import { printDeprecationWarning } from './helpers/errors';
type Thenable<T> = { then: (() => T) => mixed };
/**
* Wait for microtasks queue to flush
*/
export default function flushMicrotasksQueue<T>(): Thenable<T> {
printDeprecationWarning('flushMicrotasksQueue');
return flushMicroTasks();
}
export function flushMicroTasks<T>(): Thenable<T> {
return {
// using "thenable" instead of a Promise, because otherwise it breaks when
// using "modern" fake timers
then(resolve) {
setImmediate(resolve);
},
};
}