zerostatic
zerostatic

Reputation: 112

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

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?

Upvotes: 0

Views: 1626

Answers (2)

remotesynth
remotesynth

Reputation: 271

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.

Upvotes: 0

Tore
Tore

Reputation: 1264

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.

Upvotes: 0

Related Questions