-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Experiment with a structless variant of Yew #2957
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Visit the preview URL for this PR (updated for commit c31c47b): https://yew-rs-api--pr2957-structless-o27nw8px.web.app (expires Fri, 18 Nov 2022 04:52:04 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
|
Benchmark - SSRYew Master
Pull Request
|
flaviu-toader
pushed a commit
to flaviu-toader/yew
that referenced
this pull request
Nov 11, 2022
…oved (yewstack#2629) * Separate hydration and render queue. * Revert "Fix issue with node refs and hydration (yewstack#2597)" This reverts commit 469cc34. * Priority Render. * Add some tests. * Add more tests. * Add test result after click. * Fix test comment. * Fix test timing. * Restore test. * Once AtomicBool, now a Cell. * Prefer use_future. * Revealing of Suspense always happen after the component has re-rendered itself. * Shifting should register correct next_sibling. * Revert to HashMap. * cargo +nightly fmt. * Fix comment. * Optimise Code size? * Add comment if assertion fails. * Revert "Merge branch 'hydration-4' into fc-prepared-state" This reverts commit 427b087d4db6b2e497ad618273655bd18ba9bd01, reversing changes made to 109fcfa. * Revert "Revert "Merge branch 'hydration-4' into fc-prepared-state"" This reverts commit f1e4089. * Redo yewstack#2957.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
#2282 discusses the possibility of removing struct components. There are opinions that are both in favour of removing struct components and keeping them. However, there was no proof of concept that demonstrates what would be possible if function component becomes the only supported component type.
This pull request provides a prototype for #2282.
I do not expect this pull request to be merged, this is purely for demonstration purpose.
Currently I have only verified the
function_router
example andbenchmark_ssr
works.A short summary:
1. Lifecycles are no longer boxed
This removes many allocations.
Lifecycle events are now pure function calls and commits immediately regardless of whether being an element or component. Previously, components commit at a later lifecycle events because we need to make sure parent state is not borrowed, function components do not have this requirement.
Hence, many workarounds currently used by hydration (priority rendering, etc.) can be removed.
This is possible because the lifecycle events are much simpler for function components and they do not need to mutably borrow any parent state.
2. Many boxed types and generics are removed
Mounting a component now involves 1 allocation (
Rc<ScopeInner>
).Re-render does not involve any allocations (after
Html
is created.).The
function_router
example is now ~40KB smaller.3. SSR no longer needs to run any lifecycle events.
The hello world SSR benchmark is 100% faster than master branch.
4. Component states are no longer maintained via reference cycles.
Checklist