async-std icon indicating copy to clipboard operation
async-std copied to clipboard

How to stop and drop an interval stream?

Open reza-ebrahimi opened this issue 3 years ago • 0 comments

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 })
  }
}

reza-ebrahimi avatar Apr 12 '21 08:04 reza-ebrahimi