launchdarkly / react-native-client-sdk

LaunchDarkly Client-side SDK for React Native
Other
47 stars 32 forks source link

Decouple callback and subscription to flag changes #162

Closed marcocaldera closed 8 months ago

marcocaldera commented 1 year ago

Is your feature request related to a problem? Please describe. I was trying to listen to flag changes and I was wondering why unregisterFeatureFlagListener force us to pass a callback as an argument. What's the requirement behind it?

It also seems that unless the callback used in registerFeatureFlagListener is the same as the one used in unregisterFeatureFlagListener the system do not fully unsubscribe to that listener.

Describe the solution you'd like I would like to see decoupled the callback and subscription to a listener.

Additional context That has been my brief understanding. I'm obviously super happy to hear the reasoning.

louis-launchdarkly commented 1 year ago

Hello @marcocaldera, sorry for the late reply and thank you for the request. We will need to look into this more, as I don't know the reason off the top of my head. I will look into the answer and provide another response. For now, I am marking this as an enhancement.

yusinto commented 9 months ago

The react-native SDK has been re-written and released. The new version v10 is purely in TypeScript and supports Expo. It now uses an EventEmitter pattern for subscribing to changes. To subscribe tp changes, use the on function. You will still need to specify the callback when you unsubscribe, because internally we also use these listeners and so the client needs to know exactly which function to unsubscribe.

Please consider upgrading to v10. Thank you for your patience.

github-actions[bot] commented 8 months ago

This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.