-
Hi, I was reading this part of the book and was wondering what the point of Event::Tick is. Also, it looks like they send an Event::Render at 30 FPS consistently, but lots of apps don't need to render when nothing is happening. They only render when a key is pressed and something changes as a result. This sounds like its synchronous, but these same apps are asynchronous and use tokio and tui/ratatui (some text editors I've looked at). In fact, there already is a non-async counter app, so what is the point of the async counter app? Especially in this case, it seems wrong to render 30 FPS in an app that only changes on user input. I say all this knowing that I'm probably missing something, and I would appreciate if one of you could help me understand this. My understanding of async might be flawed. Thanks for this library and book! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This is a great question and thanks for posting it! You are right that this part of the book is sending The point of having two kinds of ticks, I think it would be possible to do everything using just one tick, i.e. I'll rework this answer into the documentation to expand on this part of it more. |
Beta Was this translation helpful? Give feedback.
-
I agree with @tz629. This tutorial is IMO a bit to synthetic to be useful. I wrote a small stopwatch example that could be a good fit for explaining the need for rendering things async, and we've also floated the idea of a pomodoro app. Realistically though, the need for async comes from doing some sort of file or network IO, not from simple applications rather than the need to update at some fixed interval like 60fps. |
Beta Was this translation helpful? Give feedback.
This is a great question and thanks for posting it!
You are right that this part of the book is sending
Event::Render
30 times a second, which is completely overkill. I think I'll change it to something more reasonable (4 times a second?) and changeEvent::Tick
to 1 time a second.The point of having two kinds of ticks,
Event::Tick
andEvent::Render
is that sometimes you want to refresh your data at a consistent rate (e.g. every 60 seconds or every second) and sometimes you want to update your UI much faster than that. This is particularly true when you are doing animations or rendering a progress bar or a spinner (which needs to be updated even then there's no user input).I think it wou…