a way to know if we're currently inside an effect tree

#16366

Development PRs

Issue

Open
R
Rich-Harris
Jul 14, 2025, 11:44 PM

Describe the problem

sveltejs/kit#13986 has this code:

try {
  $effect.pre(() => {
    // ...
  });
} catch {
  // ...
}

This is necessary because it needs to use an effect to manage the query cache, and $effect.tracking() is false when initialising a component.

Describe the proposed solution

Maybe $effect.active()?

The downside of course is that $effect.tracking() is already a source of confusion, and having $effect.active() which is very similar but subtly different will exacerbate that.

Importance

nice to have

👍 1

Info

Assignees None
Labels None
Milestone None