-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
Feature request: support promises in lifecycle components. #1204
Comments
It sounds interesting feature. IMO we could support this if it does not come with a lot of overhead. Are you referring to update state with promises? Or which feature exactly, can you add direct link please. |
Actually, I think that it will be more interesting to support promises as the return of the lifecycle methods. So, I could, for example, implement a This opens space for async rendering too. |
I think Observables is going to start showing up as another option for this sort of thing, but that would probably be a fundamentally different Component API. |
Thenables would cover more future ground as far as future interop between observables/promises are concerned. @Havunen DIO allows you to return a Promise/thenable from componentWillUnmount that defers unmounting of the DOM node to when the Promise is resolved. |
@thysultan Older versions of Inferno had something similar to this in regards to |
@trueadm Promises resolving async is what you would want in this case. Paired with class A {
componentWillUnmount(node) {
return new Promise((resolve) => {
node.animate({...keyframes}, {...options}).onfinnish = resolve
})
}
render() {
...
}
} The implementation details of this in DIO halt only the DOM nodes removal and not the execution of |
@thysultan That's the point though. Those heuristics are not right, |
@trueadm The lifecycle flow is sync in the DIO's implementation, the only aspect that is async is the resulting native DOM nodes removal and that too is only when From the scope of the virtual representation the element in question has been removed, only the related call to the native Node.removeChild(...) has been deferred. That is – returning a Promise does not change the sync nature of the |
@thysultan How do you handle use case when domNode1 is going to be replaced by domNode2, do you then defer the replaceNode call? Or do you append the next one and then call remove for the node1 later? Another use case is that when those calls are nested? And higher order component has removed node1's container |
@Havunen Something like this, Instead of |
Hey, guys!
I like a lot of this library and its performance improvements over other js libraries. However, one thing that I always have missed in React and other VirtualDom like libraries are support for promises at the component lifecycle, just like we have with Aurelia. Now, I found this feature on Dio.JS too.
Please, give a look at its documentation to understand what I'm talking (https://dio.js.org/) and give me a feedback with your thoughts. This helps a lot with animations.
The text was updated successfully, but these errors were encountered: