(resolve: T => mixed, reject: mixed => mixed)
| 133 | |
| 134 | return { |
| 135 | then(resolve: T => mixed, reject: mixed => mixed) { |
| 136 | didAwaitActCall = true; |
| 137 | thenable.then( |
| 138 | returnValue => { |
| 139 | popActScope(prevActQueue, prevActScopeDepth); |
| 140 | if (prevActScopeDepth === 0) { |
| 141 | class="cm">// We're exiting the outermost `act` scope. Flush the queue. |
| 142 | try { |
| 143 | flushActQueue(queue); |
| 144 | queueMacrotask(() => |
| 145 | class="cm">// Recursively flush tasks scheduled by a microtask. |
| 146 | recursivelyFlushAsyncActWork(returnValue, resolve, reject), |
| 147 | ); |
| 148 | } catch (error) { |
| 149 | class="cm">// `thenable` might not be a real promise, and `flushActQueue` |
| 150 | class="cm">// might throw, so we need to wrap `flushActQueue` in a |
| 151 | class="cm">// try/catch. |
| 152 | ReactSharedInternals.thrownErrors.push(error); |
| 153 | } |
| 154 | if (ReactSharedInternals.thrownErrors.length > 0) { |
| 155 | const thrownError = aggregateErrors( |
| 156 | ReactSharedInternals.thrownErrors, |
| 157 | ); |
| 158 | ReactSharedInternals.thrownErrors.length = 0; |
| 159 | reject(thrownError); |
| 160 | } |
| 161 | } else { |
| 162 | resolve(returnValue); |
| 163 | } |
| 164 | }, |
| 165 | error => { |
| 166 | popActScope(prevActQueue, prevActScopeDepth); |
| 167 | if (ReactSharedInternals.thrownErrors.length > 0) { |
| 168 | const thrownError = aggregateErrors( |
| 169 | ReactSharedInternals.thrownErrors, |
| 170 | ); |
| 171 | ReactSharedInternals.thrownErrors.length = 0; |
| 172 | reject(thrownError); |
| 173 | } else { |
| 174 | reject(error); |
| 175 | } |
| 176 | }, |
| 177 | ); |
| 178 | }, |
| 179 | }; |
| 180 | } else { |
| 181 | const returnValue: T = (result: any); |
nothing calls this directly
no test coverage detected