Reasoning for removing promise support? #425
-
I feel like callbacks are a step backwards? I have always been under the impression that promises were made to reduce "callback hell" so it seems to me removing support for promises is a wrong move. We're becoming conditioned to being able to Could someone share the reasoning for removing support for promises? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Right, so, there's both a short answer and a long answer to this question. The short answerWe're not removing Promises entirely. Promises are great, and we even encourage using them in some ways, we just don't want people to chain them on the end of a visit. The long answerThere's multiple reasons:
Back when we didn't have the Event System yet, the recommended way to show loading indicators was actually to use Promises to set a custom Now, of course it is totally okay for different developers to do things differently, but if you see a situation like this occurring more and more frequent and decide to ignore it, then over time (as a project grows in users and features) it becomes almost impossible to change it, as by that time people will have written blog posts, tweets, have plug-ins that rely on it, and otherwise recommended other people to do something in a certain way that will almost guaranteed create a situation where you'll end up upsetting a (large) portion of your users if you do eventually make the change. I hope this answers your question. |
Beta Was this translation helpful? Give feedback.
-
Thanks Claudio for that answer. I think the most important aspect is this:
I fell into the "setting a sending/loading flag then displaying a notification" camp. I think the more it sits with me, the callbacks are an efficient solution per request. The event system is also very nice. I've been a happy and faithful Inertia user since Sept 2019. I was on a very long project and didn't read the docs for a long time. The event system and forms helper are nice additions Thanks for all your work on it. Inertia is really a joy to work with. |
Beta Was this translation helpful? Give feedback.
-
@claudiodekker as pointed on #508
|
Beta Was this translation helpful? Give feedback.
Right, so, there's both a short answer and a long answer to this question.
The short answer
We're not removing Promises entirely. Promises are great, and we even encourage using them in some ways, we just don't want people to chain them on the end of a visit.
The long answer
There's multiple reasons:
Chaining promises onto the end of an
Inertia.visit
more or less relies on the side-effect of us returning the Axios request. If we at any point decide to change the way Inertia works internally in any way (which we are, hence the deprecation warning), it would/could affect everyone's promises, which is a situation we really want to avoid if we don't have to.We want to make it super clear…