move some code (#10969)

pull/10974/head
Rich Harris 6 months ago committed by GitHub
parent cebbccbcba
commit 8a758d86ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,4 @@
import { run } from '../../../common.js'; import { run_all } from '../../../common.js';
import { user_pre_effect, user_effect } from '../../reactivity/effects.js'; import { user_pre_effect, user_effect } from '../../reactivity/effects.js';
import { import {
current_component_context, current_component_context,
@ -9,6 +9,11 @@ import {
untrack untrack
} from '../../runtime.js'; } from '../../runtime.js';
/** @param {Function} fn */
function run(fn) {
return fn();
}
/** /**
* Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects * Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects
*/ */
@ -22,7 +27,7 @@ export function init() {
if (callbacks.b.length) { if (callbacks.b.length) {
user_pre_effect(() => { user_pre_effect(() => {
observe_all(context); observe_all(context);
callbacks.b.forEach(run); run_all(callbacks.b);
// beforeUpdate might change state that affects rendering, ensure the render effects following from it // beforeUpdate might change state that affects rendering, ensure the render effects following from it
// are batched up with the current run. Avoids for example child components rerunning when they're // are batched up with the current run. Avoids for example child components rerunning when they're
// now hidden because beforeUpdate did set an if block to false. // now hidden because beforeUpdate did set an if block to false.
@ -49,7 +54,7 @@ export function init() {
if (callbacks.a.length) { if (callbacks.a.length) {
user_effect(() => { user_effect(() => {
observe_all(context); observe_all(context);
callbacks.a.forEach(run); run_all(callbacks.a);
}); });
} }
} }

@ -19,8 +19,3 @@ export function run_all(arr) {
arr[i](); arr[i]();
} }
} }
/** @param {Function} fn */
export function run(fn) {
return fn();
}

@ -1,4 +1,4 @@
import { noop, run } from '../internal/common.js'; import { noop, run_all } from '../internal/common.js';
import { subscribe_to_store } from './utils.js'; import { subscribe_to_store } from './utils.js';
/** /**
@ -106,14 +106,6 @@ export function writable(value, start = noop) {
return { set, update, subscribe }; return { set, update, subscribe };
} }
/**
* @param {Function[]} fns
* @returns {void}
*/
function run_all(fns) {
fns.forEach(run);
}
/** /**
* Derived value store by synchronizing one or more readable stores and * Derived value store by synchronizing one or more readable stores and
* applying an aggregation function over its input values. * applying an aggregation function over its input values.

Loading…
Cancel
Save