Skip to content

Commit

Permalink
Merge branch 'beta' into undo-streaming-ff-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson authored Apr 5, 2024
2 parents f97f548 + fb1ad8b commit 4cf1d3f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,33 @@ stream.start(
);
```

_Close a stream_

Use the `<stream>.close()` method to close a stream.

```javascript
import { Client, fql } from "fauna"
const client = new Client()

const stream = await client.stream(fql`Product.all().toStream()`)

let count = 0;
for await (const event of stream) {
console.log(event.type)
console.log(event.data)
count++;

// Close the stream after 2 events
if (count === 2) {
console.log("Closing the stream ...")
stream.close()
break;
}
}

client.close();
```

# Contributing

Any contributions are from the community are greatly appreciated!
Expand Down

0 comments on commit 4cf1d3f

Please sign in to comment.