Skip to content

v0.2.1

Compare
Choose a tag to compare
@jkb0o jkb0o released this 17 Feb 07:25
· 20 commits to master since this release

Summary

  • the state inside asyn! is not mutable by default
  • the result arg in the asyn! may be omited
  • () now implements Into<PromiseResult>, you can return nothing from asyn!
  • add Asyn![R, S => R2, S2] macro for simplify the asyn! signature writing
  • add PromiseLike trait to group the API of promise-like constructs (then, map, ect)
  • Promise is PromiseLike itself
  • promises created from commands.promise(...) are PromiseLike, so you can chain
  • add Promise::repeat you can create async loops
  • PromiseState impl Deref/DerefMut for its value
  • add basic asyn::ui ops (awaiting for button presses)
  • more docs
  • add combine_vecs example to show how any/all works with Vec<Promise>
  • add repeat example to show how async loops work
  • add confirmation complex example to show how async ui could work
  • add system_state example to show how system params keep state between calls

Detailed

  • () now implements Into<PromiseResult>, you can return nothing from asyn!
commands.add(
  Promise::start(asyn! {
    // resolves as PromiseResult::Resolve((), ())
    info!("First call");
  })
  .then(asyn! {
    info!("Second call");
  });
  • promises created from commands.promise(...) are PromiseLike, so you can chain
// create new promise with state 0
commands
  .promise(|| 0)
  .then(asyn!(state => {
    state.value += 1;
    state.asyn().timeout(1.0)
  }))
  .then(asyn!(state => {
    info!("count: {}", state.value);
  }));  // promises execution scheduled here
  • add Promise::repeat you can create async loops
// wait 3 times and exit
commands
    .promise(|| 3)
    .then_repeat(asyn!( state => {
        info!("{}", state.value);
        state.value -= 1;
        let done = state.value == 0;
        state.asyn().timeout(1.0).with_result(if done {
        Repeat::Break(())
        } else {
        Repeat::Continue
        })
    }))
    .then(asyn!(_ => {
        asyn::app::exit()
    }));

Full Changelog: v0.2.0...v0.2.1