@@ -34,10 +34,9 @@ import { remove } from '../dom/reconciler.js';
34
34
* @param {import('./types.js').EffectType } type
35
35
* @param {(() => void | (() => void)) } fn
36
36
* @param {boolean } sync
37
- * @param {boolean } init
38
37
* @returns {import('#client').Effect }
39
38
*/
40
- export function create_effect ( type , fn , sync , init = true ) {
39
+ function create_effect ( type , fn , sync ) {
41
40
var is_root = ( type & ROOT_EFFECT ) !== 0 ;
42
41
/** @type {import('#client').Effect } */
43
42
var effect = {
@@ -61,20 +60,18 @@ export function create_effect(type, fn, sync, init = true) {
61
60
}
62
61
}
63
62
64
- if ( init ) {
65
- if ( sync ) {
66
- var previously_flushing_effect = is_flushing_effect ;
63
+ if ( sync ) {
64
+ var previously_flushing_effect = is_flushing_effect ;
67
65
68
- try {
69
- set_is_flushing_effect ( true ) ;
70
- execute_effect ( effect ) ;
71
- effect . f |= EFFECT_RAN ;
72
- } finally {
73
- set_is_flushing_effect ( previously_flushing_effect ) ;
74
- }
75
- } else {
76
- schedule_effect ( effect ) ;
66
+ try {
67
+ set_is_flushing_effect ( true ) ;
68
+ execute_effect ( effect ) ;
69
+ effect . f |= EFFECT_RAN ;
70
+ } finally {
71
+ set_is_flushing_effect ( previously_flushing_effect ) ;
77
72
}
73
+ } else {
74
+ schedule_effect ( effect ) ;
78
75
}
79
76
80
77
return effect ;
@@ -112,7 +109,7 @@ export function user_effect(fn) {
112
109
const context = /** @type {import('#client').ComponentContext } */ ( current_component_context ) ;
113
110
( context . e ??= [ ] ) . push ( fn ) ;
114
111
} else {
115
- create_effect ( EFFECT , fn , false , true ) ;
112
+ effect ( fn ) ;
116
113
}
117
114
}
118
115
0 commit comments