svelte
svelte copied to clipboard
Svelte 5: Put `unstate` on `$state` rune?
Describe the problem
Since unstate is linked to $state, it might make sense to make it a function on $state.
unstate is also a bit of an odd/non-word.
Describe the proposed solution
Not sure about the name, maybe one of
$state.remove / $state.removed
$state.clear / $state.cleared
$state.off
Importance
nice to have
putting this on the milestone in the sense of "we need to decide whether or not we want to do this until 5.0"
Domain hack-ish idea: $state.less()
We decided to keep untrack as a function, given how rare its usage is (and should be).
@dummdidumm
This was about unstate not untrack, you did see that, right?
Oops sorry - reopening . We haven't decided that one yet, though it may go in the same direction
I don't think we need a new rune for this right now. We can always leave it for now make it one later, but doing the reverse it going to be much harder.
I think the main thing that would appeal to me about making this a rune would be the possibility of doing this without wrapping the expression in a function. E.g., we could have $untrack(foo) instead of untrack(() => foo).
@Conduitry This is for unstate though, which doesn't suffer from that problem.
Oh, apologies. I can't read. Never mind!
Considering how unstate has been confused with untrack twice here in the same thread, both by major contributers (which is a great example of the oddness of unstate), I think that at least a rename should be considered. I think remove more clearly represents what unstate does ($state.remove(), removeState(), etc.), and I think the word ignore better represents what untrack does ($ignore(), $state.ignore(), ignoreState()).
I also like $state.less() as a possibility since it's shorter and clever.
I was thinking the word removed might better indicate how the function is non-destructive (like toSpliced), however, that might lead developers to expect a clone when they might not get one, i.e. if a non-reactive object is passed.
We decided that the confusion over the naming of this function warranted it being a new rune after all.
I agree with the comment on the PR that $state.clean is not the clearest name. I thought their suggestion of $state.raw or $state.toRaw was reasonable.