Skip to content

Commit 0a5628f

Browse files
committed
improve waterfall detection
1 parent c56ee71 commit 0a5628f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ export function derived(fn) {
8686
/**
8787
* @template V
8888
* @param {() => Promise<V>} fn
89+
* @param {boolean} detect_waterfall Whether to print a warning if the value is not read immediately after update
8990
* @returns {Promise<Source<V>>}
9091
*/
9192
/*#__NO_SIDE_EFFECTS__*/
92-
export function async_derived(fn) {
93+
export function async_derived(fn, detect_waterfall = true) {
9394
let parent = /** @type {Effect | null} */ (active_effect);
9495

9596
if (parent === null) {
@@ -121,7 +122,7 @@ export function async_derived(fn) {
121122

122123
internal_set(value, v);
123124

124-
if (DEV) {
125+
if (DEV && detect_waterfall) {
125126
recent_async_deriveds.add(value);
126127

127128
setTimeout(() => {

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export function template_effect(fn, sync = [], async = [], d = derived) {
358358
var restore = capture();
359359
var unsuspend = suspend();
360360

361-
Promise.all(async.map(async_derived)).then((result) => {
361+
Promise.all(async.map((expression) => async_derived(expression, false))).then((result) => {
362362
restore();
363363

364364
if ((effect.f & DESTROYED) !== 0) {

0 commit comments

Comments
 (0)