Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch top level effects to make them behave consistent with regular effects #2107

Open
titoBouzout opened this issue Mar 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@titoBouzout
Copy link
Contributor

Describe the bug

Top level effects (createEffect that isn't wrapped in a createRoot) behave inconsistently when compared with effects under a root, because top level effects aren't batched.

This isn't an issue with solid per se, as its render function already wraps in a root.

The issue is when solid is used for reactivity exclusively(besides rendering dom nodes), such when creating long-lived effects that will never be disposed, reactivity in the server; or for demo purposes (such playground snippets and the like), this inconsistency gets in the way because doesn't match expectations, it could be hard to understand why does behave this way.

It is possible that batching top level effects improve the performance of these effects.

Your Example Website or App

meaw

Steps to Reproduce the Bug or Issue

Top level effect non batched
https://playground.solidjs.com/anonymous/39d404d1-5c4a-411b-ab85-f915c82089e6

behaves differently to:

effect wrapped in a root
https://playground.solidjs.com/anonymous/d30de401-fc16-4c9a-a247-39333b970b8b
behaves the same as a top level effect that uses batch
https://playground.solidjs.com/anonymous/13b29236-c0f9-46fb-8b20-4a221fa9e4df

Expected behavior

Please batch top level effects.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

As discussed on discord, it may be about changing this line https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L357

@ryansolid
Copy link
Member

I'm still very tempted not to touch anything here until 2.0. Just because of behavior changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants