(queue: Array<RendererTask>)
| 309 | |
| 310 | let isFlushing = false; |
| 311 | function flushActQueue(queue: Array<RendererTask>) { |
| 312 | if (__DEV__) { |
| 313 | if (!isFlushing) { |
| 314 | class="cm">// Prevent re-entrance. |
| 315 | isFlushing = true; |
| 316 | let i = 0; |
| 317 | try { |
| 318 | for (; i < queue.length; i++) { |
| 319 | let callback: RendererTask = queue[i]; |
| 320 | do { |
| 321 | ReactSharedInternals.didUsePromise = false; |
| 322 | const continuation = callback(false); |
| 323 | if (continuation !== null) { |
| 324 | if (ReactSharedInternals.didUsePromise) { |
| 325 | class="cm">// The component just suspended. Yield to the main thread in |
| 326 | class="cm">// case the promise is already resolved. If so, it will ping in |
| 327 | class="cm">// a microtask and we can resume without unwinding the stack. |
| 328 | queue[i] = callback; |
| 329 | queue.splice(0, i); |
| 330 | return; |
| 331 | } |
| 332 | callback = continuation; |
| 333 | } else { |
| 334 | break; |
| 335 | } |
| 336 | } while (true); |
| 337 | } |
| 338 | class="cm">// We flushed the entire queue. |
| 339 | queue.length = 0; |
| 340 | } catch (error) { |
| 341 | class="cm">// If something throws, leave the remaining callbacks on the queue. |
| 342 | queue.splice(0, i + 1); |
| 343 | ReactSharedInternals.thrownErrors.push(error); |
| 344 | } finally { |
| 345 | isFlushing = false; |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | class="cm">// Some of our warnings attempt to detect if the `act` call is awaited by |
| 352 | class="cm">// checking in an asynchronous task. Wait a few microtasks before checking. The |
no test coverage detected