9
9
set_current_reaction
10
10
} from '../../runtime.js' ;
11
11
import { destroy_effect , pause_effect , render_effect } from '../../reactivity/effects.js' ;
12
- import { DESTROYED , INERT } from '../../constants.js' ;
13
- import { create_block } from './utils.js' ;
12
+ import { INERT } from '../../constants.js' ;
14
13
15
14
/**
16
15
* @template V
@@ -22,8 +21,6 @@ import { create_block } from './utils.js';
22
21
* @returns {void }
23
22
*/
24
23
export function await_block ( anchor , get_input , pending_fn , then_fn , catch_fn ) {
25
- const block = create_block ( ) ;
26
-
27
24
const component_context = current_component_context ;
28
25
29
26
hydrate_block_anchor ( anchor ) ;
@@ -48,7 +45,7 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
48
45
set_current_effect ( branch ) ;
49
46
set_current_reaction ( branch ) ; // TODO do we need both?
50
47
set_current_component_context ( component_context ) ;
51
- var effect = render_effect ( ( ) => fn ( anchor , value ) , { } , true ) ;
48
+ var effect = render_effect ( ( ) => fn ( anchor , value ) , true ) ;
52
49
set_current_component_context ( null ) ;
53
50
set_current_reaction ( null ) ;
54
51
set_current_effect ( null ) ;
@@ -60,18 +57,6 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
60
57
return effect ;
61
58
}
62
59
63
- /** @param {import('#client').Effect } effect */
64
- function pause ( effect ) {
65
- if ( ( effect . f & DESTROYED ) !== 0 ) return ;
66
- const block = effect . block ;
67
-
68
- pause_effect ( effect , ( ) => {
69
- // TODO make this unnecessary
70
- const dom = block ?. d ;
71
- if ( dom ) remove ( dom ) ;
72
- } ) ;
73
- }
74
-
75
60
const branch = render_effect ( ( ) => {
76
61
if ( input === ( input = get_input ( ) ) ) return ;
77
62
@@ -80,53 +65,53 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
80
65
81
66
if ( pending_fn ) {
82
67
if ( pending_effect && ( pending_effect . f & INERT ) === 0 ) {
83
- if ( pending_effect . block ?. d ) remove ( pending_effect . block . d ) ;
68
+ if ( pending_effect . dom ) remove ( pending_effect . dom ) ;
84
69
destroy_effect ( pending_effect ) ;
85
70
}
86
71
87
- pending_effect = render_effect ( ( ) => pending_fn ( anchor ) , { } , true ) ;
72
+ pending_effect = render_effect ( ( ) => pending_fn ( anchor ) , true ) ;
88
73
}
89
74
90
- if ( then_effect ) pause ( then_effect ) ;
91
- if ( catch_effect ) pause ( catch_effect ) ;
75
+ if ( then_effect ) pause_effect ( then_effect ) ;
76
+ if ( catch_effect ) pause_effect ( catch_effect ) ;
92
77
93
78
promise . then (
94
79
( value ) => {
95
80
if ( promise !== input ) return ;
96
- if ( pending_effect ) pause ( pending_effect ) ;
81
+ if ( pending_effect ) pause_effect ( pending_effect ) ;
97
82
98
83
if ( then_fn ) {
99
84
then_effect = create_effect ( then_fn , value ) ;
100
85
}
101
86
} ,
102
87
( error ) => {
103
88
if ( promise !== input ) return ;
104
- if ( pending_effect ) pause ( pending_effect ) ;
89
+ if ( pending_effect ) pause_effect ( pending_effect ) ;
105
90
106
91
if ( catch_fn ) {
107
92
catch_effect = create_effect ( catch_fn , error ) ;
108
93
}
109
94
}
110
95
) ;
111
96
} else {
112
- if ( pending_effect ) pause ( pending_effect ) ;
113
- if ( catch_effect ) pause ( catch_effect ) ;
97
+ if ( pending_effect ) pause_effect ( pending_effect ) ;
98
+ if ( catch_effect ) pause_effect ( catch_effect ) ;
114
99
115
100
if ( then_fn ) {
116
101
if ( then_effect ) {
117
- if ( then_effect . block ?. d ) remove ( then_effect . block . d ) ;
102
+ if ( then_effect . dom ) remove ( then_effect . dom ) ;
118
103
destroy_effect ( then_effect ) ;
119
104
}
120
105
121
- then_effect = render_effect ( ( ) => then_fn ( anchor , input ) , { } , true ) ;
106
+ then_effect = render_effect ( ( ) => then_fn ( anchor , input ) , true ) ;
122
107
}
123
108
}
124
- } , block ) ;
109
+ } ) ;
125
110
126
111
branch . ondestroy = ( ) => {
127
112
// TODO this sucks, tidy it up
128
- if ( pending_effect ?. block ?. d ) remove ( pending_effect . block . d ) ;
129
- if ( then_effect ?. block ?. d ) remove ( then_effect . block . d ) ;
130
- if ( catch_effect ?. block ?. d ) remove ( catch_effect . block . d ) ;
113
+ if ( pending_effect ?. dom ) remove ( pending_effect . dom ) ;
114
+ if ( then_effect ?. dom ) remove ( then_effect . dom ) ;
115
+ if ( catch_effect ?. dom ) remove ( catch_effect . dom ) ;
131
116
} ;
132
117
}
0 commit comments