Replies: 3 comments 4 replies
-
IIRC Inertia used promises at first, but people used it the same way they'd use Adios for example. Inertia doesn't work that way, it's not a replacement for Axios or similar to it, it's a router. So with a promise you'd expect just the data, while Inertia has side effects. Think that was the main reason promises from visits were removed |
Beta Was this translation helpful? Give feedback.
-
Inertia's router also provides a lot more callbacks than a simple then/catch/finally on a Promise would be able to handle. If you check the docs on manual visits, you'll see that the following are available:
Switching to promises would lose the majority of those options. |
Beta Was this translation helpful? Give feedback.
-
what about this solution? async function onSubmit(data) {
await new Promise((resolve, reject)=>{
router.patch(route('profile.update'), data, {
onSuccess: resolve,
onError: reject,
});
})
}
|
Beta Was this translation helpful? Give feedback.
-
What about we switch to
Promise
instead of relying on callbacks? I think async / await is the modern way to handle async actions.Let me provide a valid example:
This is
Ant Design
's FormonFinish
function, which relies onPromise
to automatically handle theloading
state. I have to manually wrap it in a Promise in order to make it work. This is less ideal and a bit frustrating🤣.I understand there's a
useForm
hook provided by Inertia, but when you want to integrate with some third party encapsulated forms, it's not that suitable.Beta Was this translation helpful? Give feedback.
All reactions