Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Dec 8, 2023
1 parent 3ee1e09 commit 88d40b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,7 @@ emitter.on("fatalError", (error) => {
console.log("✅ start");
console.time("🆗 close");
const cancel = emitter.start();
// cancel() to exit substreams session

// Cancel after 3 seconds
setTimeout(cancel, 3000);
```
12 changes: 11 additions & 1 deletion example.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ emitter.on("anyMessage", (message, cursor, clock) => {
console.dir(clock);
});

// End of Stream
emitter.on("close", (error) => {
if (error) {
console.error(error);
}
console.timeEnd("🆗 close");
});

// Fatal Error
emitter.on("fatalError", (error) => {
console.error(error);
Expand All @@ -60,4 +68,6 @@ emitter.on("fatalError", (error) => {
console.log("✅ start");
console.time("🆗 close");
const cancel = emitter.start();
// cancel() to exit substreams session

// Cancel after 3 seconds
setTimeout(cancel, 3000);

0 comments on commit 88d40b9

Please sign in to comment.