Retrying a trigger
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
It would be incredibly useful to retry a trigger.
There's been a common occurence in my game where I have a trigger that is activated, e.g.
`commands.spawn(ChatBubble { text: "Hello" })`
and I have a trigger set to create that chat bubble, e.g.
```rust
fn on_chat(trigger: Trigger, fonts: Res>) {
// Load font for the chat bubble
let Some(font) = fonts.get(&handle) else {
warn!("Font not yet loaded for chat bubble! Abort!");
return;
};
// Determine size of chat bubble using the font...
// Spawn chat bubble with custom size
}
```
However, if the font isn't read and loaded by the time I get this chat bubble, I lose the chance to process it, and hence, this can no longer be a trigger.
My only alternative option is to have a new system, which runs on Update, making an expensive query for any chat bubble that hasn't yet been sized.
Surely there must be a better way to reduce the amount of work in my systems.
## Proposal
Some type of new method on triggers, to say "I want you to try again next schedule update"
e.g.
```rust
fn on_chat(trigger: Trigger, fonts: Res>) {
// Load font for the chat bubble
let Some(font) = fonts.get(&handle) else {
trigger.retry_next_schedule();
return;
};
// Determine size of chat bubble using the font...
// Spawn chat bubble with custom size
}
```
Contributor guide
Research direction
Start with the on_chat example and the Trigger API, then trace how trigger callbacks are scheduled and discarded when the font lookup returns early. Define how retrying should interact with the next schedule update and repeated attempts. Done means the proposal has a documented, tested trigger-retry behavior without requiring a separate Update query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100