-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ability to invalidate a custom identifier on goto() #10659
Comments
Related #10359 |
I'm new to SvelteKit and had the same issue with CRUD delete. I currently work around it with: await goto(parentLocation)
invalidateAll() // presumably will work also for specific invalidations (I didn't know about the goto This seems to correctly cause the invalidation after the goto, so it doesn't hit the 404 between the delete and goto parent. The GET/read then doesn't need to have a default redirect to parent on not found (I'd prefer we get proper 404 when an ID doesn't exist). Not sure if this is idiomatic and feels potentially brittle? But working. If relevant, it's currently executing in an onResult callback in superforms, I'm unsure exactly how that might affect the page lifecycle so YMMV. Also wasn't exactly sure what you meant by:
So apologies if that makes this workaround not applicable. |
This issue is about having the same kind of option when using depends where |
Right, I realised that, but I'm wondering if this approach works for you for specific invalidations. That is, |
In my experience this can (randomly) trigger weird behaviors on non-basic apps through race conditions. But if I recall correctly this technique was officially documented in Sapper (SvelteKit ancester). I don't have much knowledge of SK internals so I prefer to avoid that right now. |
Running into the same issue where Would love something like what @gterras proposed.
|
Describe the problem
I know there is an issue discussing this here but this seems a wider issue.
To extend on the discussion here it could be very useful to invalidate an identifier on goto(). A common use case is as follow:
in a simple CRUD with the following pages :
Say you have a delete button on the [id] page that calls a DELETE action at the same level, if you plan to invalidate then
goto(parent_page)
the [id] load function will get in-between a not found error (obviously).goto(invalidateAll)
won't really work if you have unrelated parametrized load functions in previous segments of the URL (ie if you're usingdepends
anywhere).You can solve this by redirecting to the parent page on error in the load function but this doesn't feel right (one extra -and failed- request per deletion).
Describe the proposed solution
goto( { invalidate: ['myidentifier'] } )
Alternatives considered
I could redirect to some dummy invalidation page or add a query parameter that would trigger an invalidation in the list page but it feels complicated.
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: