Update subscription.md

This commit is contained in:
Taiki Endo 2021-03-09 22:34:29 +09:00
parent 508981acfd
commit 4a78b0460d
2 changed files with 12 additions and 10 deletions

View File

@ -11,12 +11,13 @@ struct Subscription;
#[Subscription] #[Subscription]
impl Subscription { impl Subscription {
async fn integers(&self, #[graphql(default = "1")] step: i32) -> impl Stream<Item = i32> { async fn integers(&self, #[graphql(default = 1)] step: i32) -> impl Stream<Item = i32> {
let mut value = 0; let mut value = 0;
tokio::time::interval(Duration::from_secs(1)).map(move |_| { tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(Duration::from_secs(1)))
value += step; .map(move |_| {
value value += step;
}) value
})
} }
} }
``` ```

View File

@ -11,12 +11,13 @@ struct Subscription;
#[Subscription] #[Subscription]
impl Subscription { impl Subscription {
async fn integers(&self, #[graphql(default = "1")] step: i32) -> impl Stream<Item = i32> { async fn integers(&self, #[graphql(default = 1)] step: i32) -> impl Stream<Item = i32> {
let mut value = 0; let mut value = 0;
tokio::time::interval(Duration::from_secs(1)).map(move |_| { tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(Duration::from_secs(1)))
value += step; .map(move |_| {
value value += step;
}) value
})
} }
} }
``` ```