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

Add some warning in README.md when overwriting method onmessage #44

Open
tbl0605 opened this issue Nov 24, 2021 · 0 comments
Open

Add some warning in README.md when overwriting method onmessage #44

tbl0605 opened this issue Nov 24, 2021 · 0 comments

Comments

@tbl0605
Copy link
Contributor

tbl0605 commented Nov 24, 2021

Hi,
first of all, thank you for this great library!

I recently had to dig into the library's code to understand why the property _lastEventIdwas not updated and why lastEventId was not appended to the url as I expected.
I think it would be nice to add some warning in the README.md file for following case :

  • Following code will update eventSource._lastEventId as expected:
const eventSource = new ReconnectingEventSource(...);

eventSource.addEventListener('message', event => {
    ...
});
  • But when method eventSource.onmessage is directly overwritten, the user has to manually update eventSource._lastEventId to reflect what previous code would do automatically:
const eventSource = new ReconnectingEventSource(...);

eventSource.onmessage = event => {
    eventSource._lastEventId = event.lastEventId;
    ...
};

Thank you!
Thierry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant