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

docs: Update readme #6

Closed Lenny4 closed 2 years ago

Lenny4 commented 2 years ago

@binaryminds please tell me if my explanation is clear.

wojciechkrol commented 2 years ago

Hi @Lenny4,

Thank you for contributing.

Your solution is not good and does not resolve the problem with access to the actual redux state from a listener. Since the listener is a closure it has access only to the component values from the first render. Each subsequent render has no effect on already defined listeners.

Here you have a similar situation with setInterval: https://stackoverflow.com/questions/53024496/state-not-updating-when-using-react-state-hook-within-setinterval

If you use Redux you can get the actual value directly from the store instance. Look at my example on Expo Snack: https://snack.expo.dev/@quiknull/react-native-sse-redux-example

Feel free to update docs with this solution.

Lenny4 commented 2 years ago

@wojciechkrol is it better now ?

Lenny4 commented 2 years ago

Hi @wojciechkrol , i'm still waiting for an answer

wojciechkrol commented 2 years ago

Hi @Lenny4. Thank you for the update.

Thank you!

Lenny4 commented 2 years ago

@wojciechkrol done !