You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize in advance if I'm missing some old discussion or an explanation in docs.
I've tried to use onEnter hook which was a great solution for my case of data fetching on demand.
However, I found the way I'm required to use it a bit odd. I'm talking about callback argument. Here is a question I've got: what was the idea behind using callback-based continuation style instead of Promises?
I'm using async/await syntax wich means the function will always return a Promise (even if it's just resolved data). So, instead of calling callback at the end of this function the Route can easily use received Promise to figure out the point where a component should be rendered. Here is an example:
The idea is that, if we use a callback, you have the option of resolving this synchronously.
So from the implementation's perspective, the component can either check if the result of onEnter is a Promise or just do Promise.resolve(onEnterResult) which will be resolved on the next tick anyway.
We still want to work from the lowest common denominator. Not all environments have Promise support, so we can't rely on them without an expensive polyfill.
lockbot
locked as resolved and limited conversation to collaborators
Jan 21, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I apologize in advance if I'm missing some old discussion or an explanation in docs.
I've tried to use
onEnter
hook which was a great solution for my case of data fetching on demand.However, I found the way I'm required to use it a bit odd. I'm talking about
callback
argument. Here is a question I've got: what was the idea behind using callback-based continuation style instead of Promises?I'm using
async/await
syntax wich means the function will always return a Promise (even if it's just resolved data). So, instead of callingcallback
at the end of this function theRoute
can easily use received Promise to figure out the point where a component should be rendered. Here is an example:I'd be happy to get some comments or explanation if it's possible to do or not.
Thanks,
Alexey
The text was updated successfully, but these errors were encountered: