Skip to content

Add Function Delayed Input Processing Example#3586

Merged
Madoshakalaka merged 4 commits intoyewstack:masterfrom
Enigo:master
Aug 21, 2025
Merged

Add Function Delayed Input Processing Example#3586
Madoshakalaka merged 4 commits intoyewstack:masterfrom
Enigo:master

Conversation

@Enigo
Copy link
Contributor

@Enigo Enigo commented Jan 15, 2024

Description

Hey there!
I recently encountered a scenario where I needed to develop an input form with delayed input processing. While this is quite straightforward in JavaScript using setTimeout, implementing it in Yew presented a bit more of a challenge. I realized that having a practical example of this could be really beneficial for other Yew developers. So, I've created an example to demonstrate this concept, hoping it will be a helpful resource for the community.

Checklist

  • I have reviewed my own code
  • [ ] I have added tests - not applicable

@github-actions
Copy link

github-actions bot commented Jan 15, 2024

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 99.195 99.195 0 0.000%
boids 168.005 168.005 0 0.000%
communication_child_to_parent 91.554 91.554 0 0.000%
communication_grandchild_with_grandparent 102.578 102.578 0 0.000%
communication_grandparent_to_grandchild 97.573 97.573 0 0.000%
communication_parent_to_child 87.470 87.470 0 0.000%
contexts 103.686 103.686 0 0.000%
counter 84.274 84.274 0 0.000%
counter_functional 84.623 84.623 0 0.000%
dyn_create_destroy_apps 87.274 87.274 0 0.000%
file_upload 98.170 98.170 0 0.000%
function_delayed_input N/A 91.685 N/A N/A
function_memory_game 170.059 170.059 0 0.000%
function_router 336.237 336.237 0 0.000%
function_todomvc 162.450 162.450 0 0.000%
futures 236.567 236.567 0 0.000%
game_of_life 104.362 104.362 0 0.000%
immutable 193.274 193.274 0 0.000%
inner_html 79.920 79.920 0 0.000%
js_callback 107.411 107.411 0 0.000%
keyed_list 195.425 195.425 0 0.000%
mount_point 83.287 83.287 0 0.000%
nested_list 112.415 112.415 0 0.000%
node_refs 90.649 90.649 0 0.000%
password_strength 1782.874 1782.874 0 0.000%
portals 92.442 92.442 0 0.000%
router 305.597 305.597 0 0.000%
suspense 111.410 111.410 0 0.000%
timer 88.542 88.542 0 0.000%
timer_functional 94.578 94.578 0 0.000%
todomvc 142.697 142.697 0 0.000%
two_apps 85.640 85.640 0 0.000%
web_worker_fib 134.121 134.121 0 0.000%
web_worker_prime 184.396 184.396 0 0.000%
webgl 82.856 82.856 0 0.000%

✅ None of the examples has changed their size significantly.

@Madoshakalaka
Copy link
Member

Madoshakalaka commented Aug 21, 2025

thanks for the contribution. Since this is quit old now, I took the liberty to fix some patterns.

  1. Timeout should use mut_ref as opposed to state to not cause meaningless refresh.
  2. Manual dropping is unnecessary. the Timeout is forgotten and collected in javascript when we replace the mut ref Timeout.
  3. moved some hook calls closer to the closures they are moving into to not pollute the scope.

Co-authored-by: Kirill <burnytc@gmail.com>
@Madoshakalaka
Copy link
Member

Madoshakalaka commented Aug 21, 2025

thanks for kirillsemyonkin's suggestion
4. AttrValue should be used instead of String
5. Actually simulate a delay and show a transitional message
6. use_callback as opposed to Callback::from

@kirillsemyonkin does it seem OK? added you as a co-author, you can work on top if you'd like

@Madoshakalaka Madoshakalaka enabled auto-merge (squash) August 21, 2025 17:13
@Madoshakalaka Madoshakalaka disabled auto-merge August 21, 2025 17:15
@Madoshakalaka Madoshakalaka enabled auto-merge (squash) August 21, 2025 17:17
@Madoshakalaka Madoshakalaka merged commit 0102d62 into yewstack:master Aug 21, 2025
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants