Skip to content

Commit

Permalink
Merge pull request #8 from Shopify/atesgoral/1_0_0
Browse files Browse the repository at this point in the history
1.0.0 🎉
  • Loading branch information
atesgoral authored Nov 13, 2023
2 parents 56db987 + 66f7b1f commit dc20f94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 1.0.0

- Fix example in README and deem public contract stable

# 0.3.0

- Add support for Ruby 2.6, drop rubocop-shopify
Expand Down
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
2 changes: 1 addition & 1 deletion lib/event_stream_parser/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module EventStreamParser
VERSION = '0.3.0'
VERSION = '1.0.0'
end

0 comments on commit dc20f94

Please # to comment.