Skip to content

Dynamic text #109

Description

@tyilo

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:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions