Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add conversion from UseStateSetter & UseReducerDispatcher to a Callback #3519

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

its-the-shrimp
Copy link
Contributor

Description

Implements #3510 by adding UseStateSetter::to_callback & UseReducerDispatcher::to_callback methods and From/IntoPropValue implementations to do the same thing as the methods but without cloning.

Checklist

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

Copy link

github-actions bot commented Nov 4, 2023

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.622 ns      │ 2.928 ns      │ 2.627 ns      │ 2.638 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.624 ns      │ 3.184 ns      │ 2.636 ns      │ 2.646 ns      │ 100     │ 1000000000

Copy link

github-actions bot commented Nov 4, 2023

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

https://yew-rs-api--pr3519-dispatcher2callback-cec6nvh0.web.app

(expires Sat, 11 Nov 2023 22:18:57 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link

github-actions bot commented Nov 4, 2023

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 289.244 294.614 289.866 1.670
Hello World 10 498.398 509.541 500.626 3.294
Function Router 10 1627.083 1652.982 1637.059 7.915
Concurrent Task 10 1005.807 1007.535 1006.440 0.478
Many Providers 10 1125.218 1238.746 1151.741 32.073

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 289.322 291.566 289.899 0.889
Hello World 10 501.353 515.538 506.651 5.829
Function Router 10 1621.714 1651.689 1630.417 8.808
Concurrent Task 10 1005.946 1007.142 1006.465 0.358
Many Providers 10 1155.190 1187.834 1167.373 12.983

Copy link

github-actions bot commented Nov 4, 2023

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.183 100.183 0 0.000%
boids 173.723 173.723 0 0.000%
communication_child_to_parent 92.736 92.736 0 0.000%
communication_grandchild_with_grandparent 105.764 105.764 0 0.000%
communication_grandparent_to_grandchild 101.012 101.012 0 0.000%
communication_parent_to_child 89.087 89.087 0 0.000%
contexts 105.991 105.991 0 0.000%
counter 86.119 86.119 0 0.000%
counter_functional 86.508 86.508 0 0.000%
dyn_create_destroy_apps 88.932 88.932 0 0.000%
file_upload 100.040 100.040 0 0.000%
function_memory_game 172.348 172.348 0 0.000%
function_router 348.529 348.529 0 0.000%
function_todomvc 161.180 161.180 0 0.000%
futures 229.165 229.165 0 0.000%
game_of_life 110.118 110.118 0 0.000%
immutable 185.470 185.470 0 0.000%
inner_html 79.892 79.892 0 0.000%
js_callback 109.492 109.492 0 0.000%
keyed_list 199.607 199.607 0 0.000%
mount_point 82.784 82.784 0 0.000%
nested_list 113.879 113.879 0 0.000%
node_refs 90.318 90.318 0 0.000%
password_strength 1749.734 1749.734 0 0.000%
portals 93.460 93.460 0 0.000%
router 317.424 317.424 0 0.000%
simple_ssr 140.307 140.307 0 0.000%
ssr_router 385.882 385.882 0 0.000%
suspense 115.706 115.706 0 0.000%
timer 88.551 88.551 0 0.000%
timer_functional 97.909 97.909 0 0.000%
todomvc 141.334 141.334 0 0.000%
two_apps 85.823 85.823 0 0.000%
web_worker_fib 134.743 134.743 0 0.000%
web_worker_prime 184.940 184.940 0 0.000%
webgl 82.502 82.502 0 0.000%

✅ None of the examples has changed their size significantly.

Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

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

I like this change, helpful convince methods are great!

@ranile ranile requested a review from futursolo November 5, 2023 12:27
@ranile ranile added the A-yew Area: The main yew crate label Nov 5, 2023
@futursolo futursolo merged commit 8d2cfde into yewstack:master Nov 5, 2023
geoffjay pushed a commit to geoffjay/yew that referenced this pull request Jan 25, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-yew Area: The main yew crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants