@ -8,7 +8,7 @@ import {
set _component _context ,
set _dev _stack
} from '../context.js' ;
import { get_b oundary } from '../dom/blocks/boundary.js' ;
import { B oundary } from '../dom/blocks/boundary.js' ;
import { invoke _error _boundary } from '../error-handling.js' ;
import {
active _effect ,
@ -224,12 +224,7 @@ export function unset_context() {
export function run ( thunks ) {
const restore = capture ( ) ;
var boundary = get _boundary ( ) ;
var batch = /** @type {Batch} */ ( current _batch ) ;
var blocking = boundary . is _rendered ( ) ;
boundary . update _pending _count ( 1 ) ;
batch . increment ( blocking ) ;
const decrement _pending = increment _pending ( ) ;
var active = /** @type {Effect} */ ( active _effect ) ;
@ -286,10 +281,7 @@ export function run(thunks) {
// wait one more tick, so that template effects are
// guaranteed to run before `$effect(...)`
. then ( ( ) => Promise . resolve ( ) )
. finally ( ( ) => {
boundary . update _pending _count ( - 1 ) ;
batch . decrement ( blocking ) ;
} ) ;
. finally ( decrement _pending ) ;
return blockers ;
}
@ -300,3 +292,17 @@ export function run(thunks) {
export function wait ( blockers ) {
return Promise . all ( blockers . map ( ( b ) => b . promise ) ) ;
}
export function increment _pending ( ) {
var boundary = /** @type {Boundary} */ ( /** @type {Effect} */ ( active _effect ) . b ) ;
var batch = /** @type {Batch} */ ( current _batch ) ;
var blocking = boundary . is _rendered ( ) ;
boundary . update _pending _count ( 1 ) ;
batch . increment ( blocking ) ;
return ( ) => {
boundary . update _pending _count ( - 1 ) ;
batch . decrement ( blocking ) ;
} ;
}