Using the LaunchDarkly react-client-sdk, is there a way to opt out of streamed updates just for certain flags?

877 Views Asked by At

LaunchDarkly streamed updates are turned on by default, but I'd like to ignore streamed updates for just one of my flags so it reads the new flag value only on reload. Is this possible?

2

There are 2 best solutions below

0
Tore On

From the react sdk docs:

"To enable streaming mode, specify a streaming: true attribute in your options object. When streaming is disabled, no live updates occur."

https://docs.launchdarkly.com/sdk/client-side/react/react-web

Disclaimer: I work at Statsig, a feature flagging and experimentation service. Statsig's react SDK default behavior is to not stream feature flag updates.

0
remotesynth On

The React SDK automatically subscribes to streaming updates (see documentation) However, the JavaScript SDK does not do this and you are free to use the JavaScript SDK in a React project.

In the JavaScript SDK, the updates are still streamed, but the client only responds to those updates if you subscribe to a listener for changes. So in this case, try importing the JavaScript SDK and get the flag value the "traditional" way (i.e. client.variation()). Do not implement a listener for updates and you should get the behavior that you are looking for.