Skip to content

Commit

Permalink
Update wrong example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
atesgoral committed Nov 13, 2023
1 parent 56db987 commit b01d59b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ gem install event_stream_parser

## Usage

Create a new Parser and give it a block to receive events:
Create a new Parser:

```rb
parser = EventStreamParser::Parser.new

parser.feed do |type, data, id, reconnection_time|
puts "Event type: #{type}"
puts "Event data: #{data}"
puts "Event id: #{id}"
puts "Reconnection time: #{reconnection_time}"
end
```

Then, feed it chunks as they come in:

```rb
do_something_that_yields_chunks do { |chunk| parser.feed(chunk) }
do_something_that_yields_chunks do |chunk|
parser.feed(chunk) do |type, data, id, reconnection_time|
puts "Event type: #{type}"
puts "Event data: #{data}"
puts "Event id: #{id}"
puts "Reconnection time: #{reconnection_time}"
end
end
```

Or use the `stream` method to generate a proc that you can pass to a chunk
Expand Down

0 comments on commit b01d59b

Please # to comment.