binaryminds / react-native-sse

Event Source implementation for React Native. Server-Sent Events (SSE) for iOS and Android 🚀
https://www.npmjs.com/package/react-native-sse
MIT License
175 stars 27 forks source link

fix first event is not handled #5

Closed a1exkras closed 2 years ago

a1exkras commented 2 years ago

I was struggling that the first event was not handled. That was because the first response that got into the function _handleEvent(response) was just "date:" (Thats all. Has no "\n\n") Therefore response.lastIndexOf('\n\n') returns -1 and when real event got into the method his response.substr(this.lastIndexProcessed) was like "ata: { // data // }" and data didnt get into the function dispatch

wojciechkrol commented 2 years ago

Hello @a1exkras,

Thank you for contributing!

What SSE server do you use? We use Mercure and I can't reproduce it.

a1exkras commented 2 years ago

Hello @wojciechkrol I use Spring WebFlux. Sorry for the late answer