Skip to content

$effect that separates tracking from execution ($reaction?) #12658

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

Closed
xaviergonz opened this issue Jul 29, 2024 · 1 comment
Closed

$effect that separates tracking from execution ($reaction?) #12658

xaviergonz opened this issue Jul 29, 2024 · 1 comment

Comments

@xaviergonz
Copy link

Describe the problem

In mobx there are several ways to run "effects" - https://mobx.js.org/reactions.html

  • autorun - which is the equivalent to $effect
  • reaction - allows you to pass two functions
    • a tracked function that returns a value
    • an untracked function that will run if that tracked value changes
    • an options object with things like if the reaction should run immediately or only after a first change, a comparator to compare values returned by the first function, etc.
  • when - an auto disposable reaction that runs only once when tracked method returns true (plus a cool overload that turns that into a promise)

solid.js also has something similar to reactions:

that also separates what's tracked from what should run untracked when the tracked value changes

Describe the proposed solution

Although I think this could be implemented in userland with $effect + untracked, probably it would be worth to add a $reaction rune that's already implemented in the framework?

Importance

would make my life easier

@xaviergonz xaviergonz changed the title $effect overload that separates tracking from execution ($reaction?) $effect that separates tracking from execution ($reaction?) Jul 29, 2024
@Conduitry
Copy link
Member

Duplicate of #9248.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants