async-rs / async-rs/async-std

How to stop and drop an interval stream?

Open
#970 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.1k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

I have an interval stream that will be called when a request coming, The problem is after dropping websocket connection request, the interval doesn't stop and still continue to stream values.

```rust
// async-graphql subscription
#[Subscription]
impl SystemSubscription {
// stat graphql subscription
async fn stat(&self, _ctx: &Context<'_>) -> impl Stream {
// this interval stream should stop after dropping returned stream
async_std::stream::interval(std::time::Duration::from_millis(1000)).map(|_| { 0 })
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.