Implement a way to detect whether a request has finished before actually updating the page
object
#948
arondeparon
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, both the
finished
andcompleted
events seem to trigger after thepage
object has been updated:inertia/packages/inertia/src/router.ts
Line 341 in dd59029
My use case:
I am using
current
in myPage
objects to populate a React context with default data. The problem, however, is that this context needs to be updated when the page changes. When the new page is loaded, my context object still holds the value of my previous page. Updating it from within my component results in re-rendering, which is not desirable.Currently, I reset my context by hooking into the
before
event, but this has the downside of showing a brief change of state before the request is processed.The
finish
event would be ideal, but it fires only after my new page has already been loaded, causing it to be fed with invalid data.Perhaps I am overlooking something, but it would be nice to have the ability to detect whether an XHR request has been finished/completed, before actually updating the page object.
Beta Was this translation helpful? Give feedback.
All reactions