Skip to content
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

Allow any type to be used as children #3042

Closed
wants to merge 48 commits into from

Conversation

futursolo
Copy link
Member

@futursolo futursolo commented Dec 15, 2022

Description

Partially addresses #3022.

This pull request makes the following changes:

  1. Allowing any type to be passed as children as long as IntoPropValue<T> for children with type T.
    E.g.: One can now use render props as children:

    html! {
        <Comp>
            {|p: RenderProps| html!{<>{"Hello, "}{p.name}</>}}
        </Comp>
    }
  2. Children is now a type alias of VList.

  3. Users can now choose between Children (VList), ChildrenWithProps(ChildrenRenderer<VChild<T>>)
    and Html for html-like children with various upside and downside based on their choice.

  4. When a component has only 1 child, it does not pass through an iterator and Vec.

  5. VList holds children in Rc<Vec<VNode>> hence makes it cheap to clone.

  6. VTag now holds VNode as its children type. This optimises for single child VTag by avoiding an allocation of single child VList.

Checklist

  • I have reviewed my own code
  • I have added tests

github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
@futursolo futursolo added breaking change A-yew Area: The main yew crate A-yew-macro Area: The yew-macro crate labels Dec 15, 2022
@github-actions
Copy link

github-actions bot commented Dec 15, 2022

Visit the preview URL for this PR (updated for commit d8f0178):

https://yew-rs--pr3042-make-mut-rkaxx4l8.web.app

(expires Fri, 09 Jun 2023 13:27:47 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
@github-actions
Copy link

github-actions bot commented Dec 15, 2022

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 359.920 360.164 360.039 0.080
Hello World 10 688.621 693.604 691.513 1.707
Function Router 10 2294.510 2321.381 2303.627 10.302
Concurrent Task 10 1006.778 1008.454 1007.653 0.451
Many Providers 10 1849.314 1968.644 1869.912 35.345

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 392.857 393.166 392.947 0.099
Hello World 10 640.185 645.973 643.497 1.603
Function Router 10 2135.015 2163.038 2152.890 8.521
Concurrent Task 10 1006.587 1007.832 1007.299 0.367
Many Providers 10 1521.753 1550.403 1536.899 10.735

@github-actions
Copy link

github-actions bot commented Dec 15, 2022

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 103.989 104.332 +0.343 +0.330%
boids 174.320 175.784 +1.464 +0.840%
communication_child_to_parent 96.614 97.170 +0.556 +0.575%
communication_grandchild_with_grandparent 108.877 109.416 +0.539 +0.495%
communication_grandparent_to_grandchild 105.056 105.595 +0.539 +0.513%
communication_parent_to_child 93.715 94.285 +0.570 +0.609%
contexts 109.621 109.701 +0.080 +0.073%
counter 90.216 91.318 +1.103 +1.222%
counter_functional 90.652 91.934 +1.281 +1.413%
dyn_create_destroy_apps 92.962 94.363 +1.401 +1.507%
file_upload 104.396 105.412 +1.017 +0.974%
function_memory_game 169.545 170.246 +0.701 +0.414%
function_router 338.952 343.229 +4.277 +1.262%
function_todomvc 163.585 164.670 +1.085 +0.663%
futures 227.550 229.403 +1.854 +0.815%
game_of_life 110.493 111.748 +1.255 +1.136%
immutable 189.062 190.852 +1.789 +0.946%
inner_html 86.808 87.407 +0.600 +0.691%
js_callback 113.621 114.341 +0.720 +0.633%
keyed_list 201.889 202.050 +0.161 +0.080%
mount_point 89.908 90.430 +0.521 +0.580%
nested_list 114.606 116.029 +1.423 +1.242%
node_refs 97.434 98.114 +0.681 +0.699%
password_strength 1589.523 1590.251 +0.728 +0.046%
portals 98.817 100.178 +1.360 +1.377%
router 309.236 312.852 +3.615 +1.169%
simple_ssr 145.282 146.059 +0.776 +0.534%
ssr_router 377.387 381.375 +3.988 +1.057%
suspense 111.145 112.058 +0.913 +0.822%
timer 93.052 94.030 +0.979 +1.052%
timer_functional 101.448 102.162 +0.714 +0.704%
todomvc 144.882 146.339 +1.457 +1.006%
two_apps 90.853 91.372 +0.520 +0.572%
web_worker_fib 155.089 156.469 +1.380 +0.890%
webgl 89.320 89.864 +0.544 +0.609%

⚠️ The following examples have changed their size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
counter 90.216 91.318 +1.103 +1.222%
counter_functional 90.652 91.934 +1.281 +1.413%
dyn_create_destroy_apps 92.962 94.363 +1.401 +1.507%
function_router 338.952 343.229 +4.277 +1.262%
game_of_life 110.493 111.748 +1.255 +1.136%
nested_list 114.606 116.029 +1.423 +1.242%
portals 98.817 100.178 +1.360 +1.377%
router 309.236 312.852 +3.615 +1.169%
ssr_router 377.387 381.375 +3.988 +1.057%
timer 93.052 94.030 +0.979 +1.052%
todomvc 144.882 146.339 +1.457 +1.006%

github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 15, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 21, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 21, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 21, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 21, 2022
github-actions[bot]
github-actions bot previously approved these changes Dec 21, 2022
Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you update the PR i think we could merge it.

@futursolo
Copy link
Member Author

If you update the PR i think we could merge it.

I think this pull request still needs some small tidying up around how optional types are being converted.
I will address this after #3050.

github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2023
@futursolo futursolo marked this pull request as draft April 2, 2023 16:03
@futursolo
Copy link
Member Author

Superseded by #3289.

@futursolo futursolo closed this Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate A-yew-macro Area: The yew-macro crate breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants