async-std
async-std copied to clipboard
How to stop and drop an interval stream?
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.
// async-graphql subscription
#[Subscription]
impl SystemSubscription {
// stat graphql subscription
async fn stat(&self, _ctx: &Context<'_>) -> impl Stream<Item = i32> {
// this interval stream should stop after dropping returned stream
async_std::stream::interval(std::time::Duration::from_millis(1000)).map(|_| { 0 })
}
}