Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or setup this action to publish automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@remix-sse/[email protected]
Major Changes
08b640b: Changes the API for
useSubscribe
to make an eventKey default to 'message'Using the library myself in a few projects, I have found that I don't usually need to send multiple events from the same emitter, and one eventKey usually suffices. This change will make it more ergonomic for single event emitters, while remaining flexible for multi event emitters
How to migrate
Or if you want use the default
eventKey: 'message'
you can omit it entirely7178870: Split up the single
remix-sse
package into 2 seperate packages@remix-sse/client
and@remix-sse/server
Why
Exporting both the client and server code from a single package has never sat well with me, at the start I got by releasing a single package: remix-sse for server code and remix-sse/client for client code.
This works fine if you are trasnpiling CommonJS imports, but at some point recently create-remix has started every project with type: "module" (ES Modules).
So this made our import paths quite ugly:
remix-sse/client/index.js
-Not to mention this uglier syntax was less discoverable now by language servers.
How to migrate
import 'remix-sse/client'
->import '@remix-sse/client'
import 'remix-sse'
->import '@remix-sse'
3159987: -
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 sureto 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
@remix-sse/[email protected]
Major Changes
7178870: Split up the single
remix-sse
package into 2 seperate packages@remix-sse/client
and@remix-sse/server
Why
Exporting both the client and server code from a single package has never sat well with me, at the start I got by releasing a single package: remix-sse for server code and remix-sse/client for client code.
This works fine if you are trasnpiling CommonJS imports, but at some point recently create-remix has started every project with type: "module" (ES Modules).
So this made our import paths quite ugly:
remix-sse/client/index.js
-Not to mention this uglier syntax was less discoverable now by language servers.
How to migrate
import 'remix-sse/client'
->import '@remix-sse/client'
import 'remix-sse'
->import '@remix-sse'
08b640b: Changes the API of the
EventStream
send function to make the eventKey default to 'message'Using the library myself in a few projects, I have found that I don't usually need to send multiple events from the same emitter, and one eventKey usually suffices. This change will make it more ergonomic for single event emitters, while remaining flexible for multi event emitters
How to migrate
The first argument of send is now just the data string you wish to send.
eventKey
in the second argumentreturn async () => {
clearInterval(g);
};
});
};