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

Simpler untrack call #12323

Closed
J4gQBqqR opened this issue Jul 6, 2024 · 1 comment
Closed

Simpler untrack call #12323

J4gQBqqR opened this issue Jul 6, 2024 · 1 comment

Comments

@J4gQBqqR
Copy link

J4gQBqqR commented Jul 6, 2024

Describe the problem

I found that I am using the following pattern frequently:

$effect(() => {
	data;
	untrack(() => {
		if (chart) {
			chart.data = data;
			chart.option = "some other derived runes";
			chart.update();
		}
	});
});

So data is a derived rune and used as a signal to trigger the execution of code inside of untrack block.
Inside of the untrack, there might be other state or derived runes that I do not want to track and trigger the code.

Describe the proposed solution

I would like to see if this is possible to save me from typing some extra layers of brackets:

$effect.untrack((data) => {
	if (chart) {
		chart.data = data;
		chart.option = "some other derived runes";
		chart.update();
	}
});

If the above code does not follow Javascript syntax, would this be possible?

$effect.untrack(data, () => {
	if (chart) {
		chart.data = data;
		chart.option = "some other derived runes";
		chart.update();
	}
});

My goal here is to segregate signal runes and untracked code block to avoid typing an extra ( ) => { } block.

Can we put data into the input field, or multiple runes into the input field and use these input args as trigger signals to call the untrack block?

Importance

would make my life easier

@harrisi
Copy link

harrisi commented Jul 6, 2024

Duplicate of #9248.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 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

3 participants