-
Notifications
You must be signed in to change notification settings - Fork 75
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
Async Unmounting #136
Async Unmounting #136
Conversation
60b48cf
to
8cba4fc
Compare
8cba4fc
to
27d118b
Compare
3d5030f
to
98ff753
Compare
Somehow moving src/index.ts to src/crank.ts wasn’t picked up by Git despite putting it in two separate commits. Might close and retry this PR rather than attempting to rebase 😓. |
Probably gonna have to retry this effort from scratch because of changes. 😓 |
Hi did this get picked up elsewhere or how can I follow this? Thanks! |
@Scott-HangarA Weird coincidence! I’m literally diagramming how to implement this because I can’t go to sleep, and came back to this PR because I wanted to see my old notes. I’ll create a PR soon, but I should probably have done this as an issue to track it. It will probably be put into the next version (0.4), and I’ll reference any new work in this PR, so following this PR will still keep you up to date. Here’s what I’m thinking about right now: How important is it that the position of exiting DOM nodes be preserved? Async unmounting would be so much simpler if we simply appended exiting DOM nodes to the end of whatever parent it was exiting from. Pros of ignoring the “last position” of exiting nodes:
Cons:
|
Thanks for the update! I could imagine a case where the exiting nodes might be needed in the same order. For example, using Material-ui it creates dropdowns/ drawers/ modals in nodes at the bottom of the page outside of the parent node. This raises the question (for me anyways) of what happens when someone has, let's say, a drawer open, and then navigates away? Below is an example from https://material-ui.com/components/drawers/ |
This was me trying to figure out where exiting nodes should go at 6 AM this morning haha. Like, if you have nodes The real mind-f*ck which I don’t want to deal with is when you have multiple sets of exiting nodes which overlap in terms of when they’re exiting, where should they all be placed relative to each other. Yes, the trick these exiting animations use is to recreate the original layout of the exiting nodes using fixed positioning and css transforms, but ideally we’d want to be able to preserve the DOM nodes where they were originally so we don’t have to do all that layout measurement. |
WIP on Async Unmounting API.
Elements should be able to linger in the DOM for longer than they’re in the virtual element tree. This is primarily useful for exit animations. We don’t want every component to unmount asynchronously. After some dogfooding I think the following conditions feel the most ergonomic:
cleanup
method is called with a callback which returns a promise. This is the main mechanism behind async unmounting. Bonus points if we can somehow exclude async generator components which return immediately from this logic. *** Coming back to this list. I’m not 100% sure this should be a requirement.
** Coming back to this list again. I’m beginning to think we should exclusively use cleanup callbacks and ignore
return()
stuff. The reason being it’s pretty easy to deadlock an async generator and I don’t want lingering in that case.Related issues in other repositories.
July 27th 2020
I have async unmounting mostly working. Check out the transitions directory in the examples, which does the d3 enter-update-exit letters thingy. I need to write tests, which will be a pain.
The only thing blocking merge is I wanted to do async unmounting while also making performance upgrades. Specifically, the introduction of a “remove” method on the internal renderer API, and coordination of the “arrange” and “remove” methods. I’ve made one pass, but my current thinking is we have to change the return types of the “update”/“commit” methods, which is a refactoring I just don’t feel like doing right now. This would involve bringing back to life the “dirty start”/“dirty end” optimizations. Probably will pick this back up in a month.
Open questions: