Closed dan-cooke closed 7 months ago
Latest commit: 1aa6d3773da990642ed6ebb7dbf7ed6b2d81184b
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
useSubscribe
changed to take anEventSource
useEventStream
hook to be superseeduseSubscribe
as the ergonomic way of listening to eventsuseEventSource
RemixSseProvider
No more boilerplate
I wasn't happy with the amount of boilerplate even after making several changes like making the eventKey default to 'message'
The library should not provide the context, if users want to share their event sources across their app they are free to do so, but
remix-sse
should not care about this.So the following changes all have the intention of making the library easier to get started with.
How to migrate
useSubscribe
now takes anEventSource
This was purely to make room for the next change
useEventStream
is the MVP nowUse this hook wherever possible, it will create the EventSource for you and call
useSubscribe
making sure to not duplicate Eventsources to the same URL using a simple map.Removed the context and useEventStream
No need for a context, we can just store a url -> event source map globally