Skip to content

Svelte 5: Put unstate on $state rune? #10421

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
brunnerh opened this issue Feb 7, 2024 · 12 comments · Fixed by #11180
Closed

Svelte 5: Put unstate on $state rune? #10421

brunnerh opened this issue Feb 7, 2024 · 12 comments · Fixed by #11180
Assignees
Labels
Milestone

Comments

@brunnerh
Copy link
Member

brunnerh commented Feb 7, 2024

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

@dummdidumm dummdidumm added this to the 5.0 milestone Feb 8, 2024
@dummdidumm
Copy link
Member

putting this on the milestone in the sense of "we need to decide whether or not we want to do this until 5.0"

@Not-Jayden
Copy link
Contributor

Domain hack-ish idea: $state.less()

@dummdidumm
Copy link
Member

We decided to keep untrack as a function, given how rare its usage is (and should be).

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2024
@brunnerh
Copy link
Member Author

brunnerh commented Apr 6, 2024

@dummdidumm
This was about unstate not untrack, you did see that, right?

@dummdidumm
Copy link
Member

dummdidumm commented Apr 6, 2024

Oops sorry - reopening . We haven't decided that one yet, though it may go in the same direction

@dummdidumm dummdidumm reopened this Apr 6, 2024
@trueadm
Copy link
Contributor

trueadm commented Apr 8, 2024

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.

@Conduitry
Copy link
Member

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).

@trueadm
Copy link
Contributor

trueadm commented Apr 8, 2024

@Conduitry This is for unstate though, which doesn't suffer from that problem.

@Conduitry
Copy link
Member

Oh, apologies. I can't read. Never mind!

@apokaliptis
Copy link

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.

@trueadm
Copy link
Contributor

trueadm commented Apr 15, 2024

We decided that the confusion over the naming of this function warranted it being a new rune after all.

@benmccann
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants