Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated session buffer modification methods #52

Open
MatthewWid opened this issue Sep 25, 2023 · 0 comments
Open

Remove deprecated session buffer modification methods #52

MatthewWid opened this issue Sep 25, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@MatthewWid
Copy link
Owner

MatthewWid commented Sep 25, 2023

Once #42 is implemented, the ability to directly modify the internal session buffer with the .event, .data, .id, .retry, .comment, .dispatch and .flush methods will be moved into a separate EventBuffer class that Session will create and use internally.

As such, these methods and the ability to modify the internal session buffer at all will become redundant as you can instead just instantiate a new EventBuffer yourself and write its data directly to the socket.


For example, where before you would modify the session buffer yourself to write individual fields:

const session = await createSession(req, res);

session
  .event("my-event")
  .id("my-custom-id")
  .data("my data 1")
  .data("my data 2")
  .dispatch()
  .flush();

You can now create your own buffer instead:

const buffer = createEventBuffer();

buffer
  .event("my-event")
  .id("my-custom-id")
  .data("my data 1")
  .data("my data 2")
  .dispatch();

res.write(buffer.read());

(The above code is not necessarily what the final API will look like.)


This avoids the need to instantiate an entire Session instance for users who simply want an easy way to write spec-compliant SSE fields over the wire, as well as reducing the API surface size for users who follow the most common use-case of only using the helper methods (.push, .stream and .iterate).


The aforementioned methods on the Session class are now deprecated and will be removed in the future. Possibly in version 1.0.0.

@MatthewWid MatthewWid added the enhancement New feature or request label Sep 25, 2023
@MatthewWid MatthewWid self-assigned this Sep 25, 2023
@MatthewWid MatthewWid changed the title Remove session buffer modification Remove deprecated session buffer modification methods Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant