emilk / emilk/egui

Investigate async?

Open
#2,242 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Is your feature request related to a problem? Please describe.**

Currently egui re-runs your entire GUI every time it updates.

**Describe the solution you'd like**

Why not use async? As an example of "async point" where async would be helpful, consider everything that currently takes FnOnce, such as `ui.horizontal`.

By keeping track of what kinds of updates trigger certain events, egui could make use of a custom async executor to figure out when to update things. For example:

```rust
fn ui_counter(ui: &mut egui::Ui, counter: &mut i32) {
// Put the buttons and label on the same row:
ui.horizontal(|ui| {
if ui.button("-").clicked() {
*counter -= 1;
}
ui.label(counter.to_string());
if ui.button("+").clicked() {
*counter += 1;
}
});
}
```

(example taken from docs)

Here, egui knows about 3 things: there's a horizontal section, there are 2 buttons in it, and the buttons are queried for clicked events. So, egui could simply refresh only the horizontal section when any of the buttons are clicked, without having to rebuild the whole GUI. This doesn't even require making it async but just making it not FnOnce, tho the convenience of async is that it makes lifetimes a lot happier.

**Describe alternatives you've considered**

N/A

**Additional context**

N/A

Contributor guide

Open the contributing guide

Research direction

Start with the documented ui.horizontal example and inspect how its FnOnce closure and button events are currently handled. Compare the full-GUI rerun behavior with the proposed async, custom-executor, or partial-refresh approach. The issue names no files or tests and provides no concrete completion criterion, so scope and validation need maintainer agreement.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.