Skip to content

Commit 8a758d8

Browse files
authored
move some code (#10969)
1 parent cebbccb commit 8a758d8

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

packages/svelte/src/internal/client/dom/legacy/lifecycle.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { run } from '../../../common.js';
1+
import { run_all } from '../../../common.js';
22
import { user_pre_effect, user_effect } from '../../reactivity/effects.js';
33
import {
44
current_component_context,
@@ -9,6 +9,11 @@ import {
99
untrack
1010
} from '../../runtime.js';
1111

12+
/** @param {Function} fn */
13+
function run(fn) {
14+
return fn();
15+
}
16+
1217
/**
1318
* Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects
1419
*/
@@ -22,7 +27,7 @@ export function init() {
2227
if (callbacks.b.length) {
2328
user_pre_effect(() => {
2429
observe_all(context);
25-
callbacks.b.forEach(run);
30+
run_all(callbacks.b);
2631
// beforeUpdate might change state that affects rendering, ensure the render effects following from it
2732
// are batched up with the current run. Avoids for example child components rerunning when they're
2833
// now hidden because beforeUpdate did set an if block to false.
@@ -49,7 +54,7 @@ export function init() {
4954
if (callbacks.a.length) {
5055
user_effect(() => {
5156
observe_all(context);
52-
callbacks.a.forEach(run);
57+
run_all(callbacks.a);
5358
});
5459
}
5560
}

packages/svelte/src/internal/common.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,3 @@ export function run_all(arr) {
1919
arr[i]();
2020
}
2121
}
22-
23-
/** @param {Function} fn */
24-
export function run(fn) {
25-
return fn();
26-
}

packages/svelte/src/store/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { noop, run } from '../internal/common.js';
1+
import { noop, run_all } from '../internal/common.js';
22
import { subscribe_to_store } from './utils.js';
33

44
/**
@@ -106,14 +106,6 @@ export function writable(value, start = noop) {
106106
return { set, update, subscribe };
107107
}
108108

109-
/**
110-
* @param {Function[]} fns
111-
* @returns {void}
112-
*/
113-
function run_all(fns) {
114-
fns.forEach(run);
115-
}
116-
117109
/**
118110
* Derived value store by synchronizing one or more readable stores and
119111
* applying an aggregation function over its input values.

0 commit comments

Comments
 (0)