Hacker News new | ask | show | jobs
by meltedcapacitor 1359 days ago
Seems a weird mix of async and callbacks spaghetti.

I´d expect an async UI to be in "immediate UI" style, e.g.:

  async fn give_em_cookies(window:Win) {
    win.title("Cookies!");
    win.columnwise();
    win.label("Which cookie do you like?");
    let cookie = win.selector(&["Shortbread", "Chocolate chip"]).await;
    win.label("When to you want to eat the cookie?");
    win.rowwise();
    if win.button("Now!").await   { eat_cookie_now(cookie); }
    if win.button("Later!").await { eat_coookie_later(cookie); }
    if win.closed().await { no_cookie_eaten(); }
  }

  // the function represents the state machine that encodes
  // the behaviour of the dialog box, which the caller gives to UI
  // engine for rendering
  ui.display(give_em_cookies(Window::new())).await;