-
Notifications
You must be signed in to change notification settings - Fork 32
Enable initializing multiple clients #10
Description
Is your feature request related to a problem? Please describe.
Yes. I'm working on an app that allows the user to toggle between multiple environments (staging, production, etc.). Each environment corresponds to a different database and a different LaunchDarkly environment with different targeting rules.
The problem I'm having is that the user gets "stuck" with the feature flag values for the first environment they select. For example, if the user chooses "production", the app initializes a LaunchDarkly client with the mobileKey for production. That way, the client provides the appropriate feature flag values for the production environment. However, if the user then toggles to the "staging" environment, the client still provides the feature flag values for production.
I attempted to create a different client for each environment, but when I tried to initialize a second client, I got an error: "Client was already initialized".
Describe the solution you'd like
I'd like to be able to create multiple client instances, just as I can with the Node SDK.
Describe alternatives you've considered
I can think of a couple alternate approaches:
- Allow the SDK user to destroy the existing client instance and create a new one to replace it
- Allow the SDK user to update the client configuration options (including mobileKey) for a client that's already been initialized
Either of these solutions would work for me as well. I'm not sure which of the three options is easiest to implement.
Additional context
I'm really enjoying working with this SDK - thanks so much for making it available!