src/content/docs/tutorials/counter-app/_multiple-files/main.md
Putting it all together, we have the main.rs function:
{{#include @code/tutorials/ratatui-counter-app/src/main.rs:imports_main}}
{{#include @code/tutorials/ratatui-counter-app/src/main.rs:main}}
Because we call tui.events.next() in a loop, it blocks until there's an event generated. If
there's a key press, the state updates and the UI is refreshed. If there's no key press, a Tick
event is generated every 250 milliseconds, which causes the UI to be refreshed.
This is what it looks like in practice to:
j 5 timesk 5 timesqYou can find the full source code for this multiple files tutorial here: https://github.com/ratatui/ratatui-website/tree/main/code/tutorials/ratatui-counter-app.
:::note[Homework]
Right now, this TUI application will render every time a key is pressed. As an exercise, can you make this app render only an a predefined tick rate?
:::