Merge pull request #439 from taiki-e/docs-subscription

Update subscription.md
This commit is contained in:
Sunli 2021-03-10 09:06:32 +08:00 committed by GitHub
commit 26a55146da
2 changed files with 12 additions and 10 deletions

View File

@ -11,12 +11,13 @@ struct Subscription;
#[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;
tokio::time::interval(Duration::from_secs(1)).map(move |_| {
value += step;
value
})
tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(Duration::from_secs(1)))
.map(move |_| {
value += step;
value
})
}
}
```

View File

@ -11,12 +11,13 @@ struct Subscription;
#[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;
tokio::time::interval(Duration::from_secs(1)).map(move |_| {
value += step;
value
})
tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(Duration::from_secs(1)))
.map(move |_| {
value += step;
value
})
}
}
```