Skip to content

introduce a method like $effect.evey that works on changing any reactive value and not depend on the last read value #14882

@gchiocchio3git

Description

@gchiocchio3git

Describe the problem

Thanks for your work. We are migrating from v4 to v5 and were wondering if it would be possible to add an additional $effect.every rune to handle cases that currently work perfectly with v4 but would require a complete rewrite in v5.

An effect only depends on the values that it read the last time it ran. If a is true, changes to b will [not cause this effect to rerun]

$effect(() => {
console.log('running');

if (a || b) {
	console.log('inside if block');
}

});

we have Svelte 4 code like this :

$: {
console.log('running');

if (a || b) {
	console.log('inside if block');
}

}

and it would be nice 'inside if block' is printed at every change of a and b. This would be useful as well as save us time in migrating from v4 to v5

Describe the proposed solution

introduce the rune $effect.every force rerun on every state change which does not depend on the last read value

example:

$effect.every(() => {
console.log('running');

if (a || b) {
	console.log('inside if block');
}

});

'inside if block' is printed if a or b is changed.

Thanks!

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions