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

Add generic type hints to boxed hooks #3633

Merged
merged 2 commits into from Mar 14, 2024

Conversation

Ichmed
Copy link
Contributor

@Ichmed Ichmed commented Mar 13, 2024

Description

When using complex type constructs in a boxed hook, the compiler can get confused and request a type hint on the call to the inner function.
This PR simply adds all generic types of the outer hook function as explicit types to the call of the inner function.

Checklist

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

Copy link

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

https://yew-rs-api--pr3633-add-hook-generics-grxmbo3f.web.app

(expires Wed, 20 Mar 2024 19:07:31 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 308.859 312.050 309.489 1.064
Hello World 10 498.883 515.105 504.849 6.130
Function Router 10 1626.023 1661.016 1642.295 13.830
Concurrent Task 10 1005.199 1007.640 1006.563 0.726
Many Providers 10 1109.117 1158.613 1129.117 15.892

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 308.859 309.384 309.048 0.192
Hello World 10 504.706 517.374 512.572 5.031
Function Router 10 1638.529 1672.063 1656.714 11.125
Concurrent Task 10 1005.631 1007.171 1006.323 0.519
Many Providers 10 1154.007 1238.911 1182.157 29.464

Copy link

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 99.057 99.057 0 0.000%
boids 171.409 171.409 0 0.000%
communication_child_to_parent 91.683 91.683 0 0.000%
communication_grandchild_with_grandparent 103.871 103.871 0 0.000%
communication_grandparent_to_grandchild 99.243 99.243 0 0.000%
communication_parent_to_child 87.991 87.991 0 0.000%
contexts 103.900 103.900 0 0.000%
counter 84.960 84.960 0 0.000%
counter_functional 85.068 85.068 0 0.000%
dyn_create_destroy_apps 87.970 87.970 0 0.000%
file_upload 98.954 98.954 0 0.000%
function_memory_game 169.634 169.634 0 0.000%
function_router 346.245 346.245 0 0.000%
function_todomvc 159.937 159.937 0 0.000%
futures 227.395 227.395 0 0.000%
game_of_life 108.615 108.615 0 0.000%
immutable 188.743 188.743 0 0.000%
inner_html 78.793 78.793 0 0.000%
js_callback 107.322 107.322 0 0.000%
keyed_list 196.957 196.957 0 0.000%
mount_point 81.663 81.663 0 0.000%
nested_list 112.687 112.687 0 0.000%
node_refs 89.179 89.179 0 0.000%
password_strength 1707.426 1707.426 0 0.000%
portals 92.161 92.161 0 0.000%
router 315.510 315.510 0 0.000%
simple_ssr 139.191 139.191 0 0.000%
ssr_router 383.709 383.709 0 0.000%
suspense 114.030 114.030 0 0.000%
timer 87.457 87.457 0 0.000%
timer_functional 96.294 96.294 0 0.000%
todomvc 140.661 140.661 0 0.000%
two_apps 84.355 84.355 0 0.000%
web_worker_fib 133.981 133.981 0 0.000%
web_worker_prime 184.136 184.136 0 0.000%
webgl 81.479 81.479 0 0.000%

✅ None of the examples has changed their size significantly.

Copy link
Member

@hamza1311 hamza1311 left a comment

Choose a reason for hiding this comment

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

Thanks!

@hamza1311 hamza1311 added the A-yew-macro Area: The yew-macro crate label Mar 13, 2024
Copy link
Member

@WorldSEnder WorldSEnder left a comment

Choose a reason for hiding this comment

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

Sweet and simple, thanks for the PR 👍

@WorldSEnder WorldSEnder merged commit e9739fc into yewstack:master Mar 14, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-macro Area: The yew-macro crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants