Closed dan-cooke closed 8 months ago
Latest commit: bf6abe9af2a6f8dfe1475926efc01e8cb5939310
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
@remix-sse/client
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 entirely@remix-sse/server
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 argumentexport const loader: LoaderFunction = ({ request }) => { return new EventStream(request, (send) => { let gIndex = 0; let g = setInterval(() => { gIndex += 1; --- send('message', JSON.stringify({ hello: 'world', index: gIndex })); +++ send(JSON.stringify({ hello: 'world', index: gIndex })); }, 1000);
}); };