jdx / jdx/demand

Dynamic text

Open
#109 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
257
Forks
18
Avg merge
4h 54m
Merged PRs (30d)
11

Description

I have a use-case where I need to update the `title`/`description` for a `Select` in another thread. Currently I can't use `demand` at all for this part.

Maybe this is out of scope for `demand`, but it would be nice if it was possible to do something like:
```rust
let price = 100;

let handle = Select::new(format!("Coins inserted: 0, price: {price}"))
.option(DemandOption::new("Complete payment"))
.option(DemandOption::new("Quit"))
.run_in_thread();

{
let handle = handle.clone();
std::thread::spawn(move || {
loop {
// fetch coins inserted
let balance = ...;

handle.set_title(format!("Coins inserted: {balance}, price: {price}"));

sleep(Duration::from_secs(1));
}
});
}

let result = handle.wait();
```


If you want to support this it might also make sense to make the options dynamic, but I think that would be harder to do.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.