v0.2.1
Summary
- the state inside
asyn!
is not mutable by default - the result arg in the
asyn!
may be omited ()
now implementsInto<PromiseResult>
, you can return nothing fromasyn!
- add
Asyn![R, S => R2, S2]
macro for simplify theasyn!
signature writing - add
PromiseLike
trait to group the API of promise-like constructs (then, map, ect) Promise
isPromiseLike
itself- promises created from
commands.promise(...)
arePromiseLike
, so you can chain - add
Promise::repeat
you can create async loops PromiseState
implDeref
/DerefMut
for its value- add basic
asyn::ui
ops (awaiting for button presses) - more docs
- add
combine_vecs
example to show howany/all
works withVec<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 implementsInto<PromiseResult>
, you can return nothing fromasyn!
commands.add(
Promise::start(asyn! {
// resolves as PromiseResult::Resolve((), ())
info!("First call");
})
.then(asyn! {
info!("Second call");
});
- promises created from
commands.promise(...)
arePromiseLike
, 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