Add some warning in README.md when overwriting method onmessage
Opened this issue · 0 comments
tbl0605 commented
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 _lastEventId
was 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 updateeventSource._lastEventId
to reflect what previous code would do automatically:
const eventSource = new ReconnectingEventSource(...);
eventSource.onmessage = event => {
eventSource._lastEventId = event.lastEventId;
...
};
Thank you!
Thierry.