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

Changes on mirror value doesn't trigger reactivity #7730

Closed
aguspdana opened this issue Jul 27, 2022 · 1 comment
Closed

Changes on mirror value doesn't trigger reactivity #7730

aguspdana opened this issue Jul 27, 2022 · 1 comment

Comments

@aguspdana
Copy link

aguspdana commented Jul 27, 2022

Describe the bug

When a mirrored value changes through a reactivity to another value, it doesn't trigger further reactivity on blocks that depend on it or components that indirectly depend on it.

Reproduction

<script>
	let source = 0;
	let mirror = 0;
	$: isMirrorZero = mirror === 0;

	// Changes on mirror doesn't trigger this block when it's changed by syncMirror.
	$: {
		const id = Math.floor(Math.random() * 100);
		console.log(`${id}. source: ${source}; mirror: ${mirror}`)
		setTimeout(() => {console.log(`${id}. mirror later: ${mirror}`)}, 1)
	}
	
	$: syncMirror(source);
	
	function syncMirror(s) {
		if (mirror !== s) {
			mirror = s;
		}
	}

	function handleClick() {
		source++
	}
</script>

<button on:click={handleClick}>
	Source: {source}
</button>
<p>
	Mirror: {mirror}
</p>

{#if isMirrorZero}
	<p>
		This should not appear when mirror is not zero
	</p>
{/if}

Logs

No response

System Info

Repl

Severity

annoyance

@Conduitry
Copy link
Member

This is the intended behavior. Duplicate of #3361, #5190, #5848, #5905. #7612, and probably others. See in particular my comment on #5848.

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