-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Easy timeout/setInterval #131
Comments
interval seems to me more like a subscription than order/cmd. So I think it would make more sense to use it like e.g. keyboard events - in Alternative can be also something like this: orders.subscribe(Sub::interval(1000, Msg::Tick)); timeout makes more sense imho, but we can reuse existing Api and be prepared for more similar cases - i.e. something like: orders.perform_cmd(Cmd::timeout(500, Msg::Delayed)); So it's clear on the first look that it's a command and we can easily add more commands in the future. |
Is there a way to use stream now? I wanted to make an API call each X seconds. I tried to use
But I get:
Is there a workaround for now? |
let stream = IntervalStream::new(1_000).for_each(move |_| {
let condition = true;
if !condition {
return Err(())
}
app.update(msg_mapper(Msg::DoSomething));
Ok(())
})
.then(|_| Ok(Msg::Finished));
orders.perform_cmd(stream); We should return back to this issue once |
It would be great to have a easy way to schedule timeouts and intervals.
Something like:
As mentioned in the futures cancellation issue, it would be great to return a drop guard that clears the timeout/interval when dropped.
For inspiration, draco does it this way.
The text was updated successfully, but these errors were encountered: