Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrunic committed May 7, 2020
1 parent a17d5c0 commit f81028c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const server = fastify();
server.register(FastifySSEPlugin);

server.get("/", function (req, res) {
res.sse(async function * source () {
res.sse((async function * source () {
for (let i = 0; i < 10; i++) {
sleep(2000);
yield {id: String(i), data: "Some message"};
}
});
})());
});
```

Expand All @@ -45,12 +45,13 @@ const server = fastify();
server.register(FastifySSEPlugin);

server.get("/", function (req, res) {
const eventEmitter = new EventEmitter();
res.sse(new EventIterator(
({ push }) => {
this.addEventListener("some_event", push)
return () => this.removeEventListener("some_event", push)
eventEmitter.on("some_event", push)
return () => eventEmitter.removeEventListener("some_event", push)
}
)
);
});
```
```

0 comments on commit f81028c

Please sign in to comment.