( transition: Transition, thenable: Thenable<S>, )
| 69 | let needsIsomorphicIndicator: boolean = false; |
| 70 | |
| 71 | export function entangleAsyncAction<S>( |
| 72 | transition: Transition, |
| 73 | thenable: Thenable<S>, |
| 74 | ): Thenable<S> { |
| 75 | // `thenable` is the return value of the async action scope function. Create |
| 76 | // a combined thenable that resolves once every entangled scope function |
| 77 | // has finished. |
| 78 | if (currentEntangledListeners === null) { |
| 79 | // There's no outer async action scope. Create a new one. |
| 80 | const entangledListeners = (currentEntangledListeners = []); |
| 81 | currentEntangledPendingCount = 0; |
| 82 | currentEntangledLane = requestTransitionLane(transition); |
| 83 | const entangledThenable: Thenable<void> = { |
| 84 | status: 'pending', |
| 85 | value: undefined, |
| 86 | then(resolve: void => mixed) { |
| 87 | entangledListeners.push(resolve); |
| 88 | }, |
| 89 | }; |
| 90 | currentEntangledActionThenable = entangledThenable; |
| 91 | if (enableDefaultTransitionIndicator) { |
| 92 | needsIsomorphicIndicator = true; |
| 93 | // We'll check if we need a default indicator in a microtask. Ensure |
| 94 | // we have this scheduled even if no root is scheduled. |
| 95 | ensureScheduleIsScheduled(); |
| 96 | } |
| 97 | } |
| 98 | currentEntangledPendingCount++; |
| 99 | thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); |
| 100 | return thenable; |
| 101 | } |
| 102 | |
| 103 | function pingEngtangledActionScope() { |
| 104 | if (--currentEntangledPendingCount === 0) { |
no test coverage detected