Skip to content

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

Open
@tbl0605

Description

@tbl0605

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions