Skip to content

need event of some type to update #1026

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

Open
littleblack111 opened this issue Apr 2, 2025 · 2 comments
Open

need event of some type to update #1026

littleblack111 opened this issue Apr 2, 2025 · 2 comments

Comments

@littleblack111
Copy link

i have a socket server
server's mouse don't move, client connect
server UI(log) won't update until mouse or keyboard events(or any events)

temp solution: screen.postevent(Event::Custom)

@ArthurSonzogni
Copy link
Owner

Yes, that work. Alternatively, you could use:

ScreenInteractive::Active()->RequestAnimationFrame();

This is almost equivalent, but avoid running the OnEvent() on the component. It also squash the request together if they are emitted very frequently.


Note that if you want to yield while running the FTXUI loop, you can use a custom loop:

  Loop loop(&screen, component);
  while (!loop.HasQuitted()) {
    //...Do something like pooling the server.
 
    // ... Handle the events from the user and refresh the terminal view.
    loop.RunOnce();

    // Don't waste too much CPU.
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
  }

See Example Demo


Please let me know if that answer you question.

@littleblack111
Copy link
Author

Yes, that work. Alternatively, you could use:

ScreenInteractive::Active()->RequestAnimationFrame();

This is almost equivalent, but avoid running the OnEvent() on the component. It also squash the request together if they are emitted very frequently.


Note that if you want to yield while running the FTXUI loop, you can use a custom loop:

  Loop loop(&screen, component);
  while (!loop.HasQuitted()) {
    //...Do something like pooling the server.
 
    // ... Handle the events from the user and refresh the terminal view.
    loop.RunOnce();

    // Don't waste too much CPU.
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
  }

See Example Demo


Please let me know if that answer you question.

Cool, thanks for sharing the alternative way, however I'm still confused on why is this necessary at the first place

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

No branches or pull requests

2 participants