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

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?

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.

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.

Related

When using twilio to generate web app to web app voice calls how can I switch to handheld or loudspeaker based on the user selection from client side

Using ReactJS as the client-side,
Are there any build-in functions in "Twilio.Device" that I can use
there are some function related to audio in Twilio.Device.audio
referred the docs: https://www.twilio.com/docs/voice/sdks/javascript/overview-1x-deprecated/device
but haven't got any exact solution
Twilio developer evangelist here.
First, not all browsers support setting the output destination, so be aware of that.
For browsers that do support it, the device object has an audio property which has an availableOutputDevices property that lists the available destinations. There is a vanilla JS example in the documentation for creating a drop down menu and updating the audio output. I recommend you take a look at that and translate it to React.

Integrating Push API Persistence

I'm trying to integrate persistent push notification with Push API in a PWA, i saw in the docs that it's possible to do that but i can't see any example or what so ever to do that, is there a tutorial that can help me achieve that ?
You need to set the requireInteraction flag in order to make a notification persistent (i.e. do not hide it after a few seconds automatically).
Currently this flag is supported only by some browsers.
Here you can find more information:
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification

How does whatsappweb deliver updates?

I'm wondering how does whatsappweb deliver updates?
Do you ever notice a left green card appearing sometimes and asking you to click in a link to refresh page and run the new whatsappweb fresh code updated.
I'm almost sure they use webpack, service workers etc.
Chances are that you already had cache problems using webpack where even refreshing page it remains cached.
So how does whatsappweb solved this issue with a single refresh link?
They use a service worker, if the service worker gets updated, they trigger something in the react app, is easy to do it.
serviceWorker.register({ onUpdate: () => {console.log('new service worker')}});
just dispatch something instead of the console.log
Webpack is a building tool and isn't involved anywhere on a live site. While it offers Hot Module Reload for the development server you will not get it on the production version.
Unlike traditional desktop applications, delivering updates for websites is as straightforward as updating the files on your server (and invalidating any browser caches). You don't need to notify the user to download something, a simple refresh will get the new pages.
If you really want instantaneous updates (without waiting for the user to refresh the page) you can create some sort of WebSocket communication which when a message is received triggers a browser refresh. Nothing special and no deployment mechanisms involved.

React and UI updates on data changes (via backend)

Learning a little React currently. I'm finding myself confused about some of the utility here. One sticking point that seems to (for me, at least) undermine it's value is that If I want to sync my UI to data residing on the server (which can and will change), I need to manually poll the server? Aside from component-based architecture, I'm not sure how this is getting me further than well structured and logically implemented AJAX. Even in the React docs, they're using JQuery in this regard. https://facebook.github.io/react/docs/tutorial.html#updating-state
I'm sure I'm missing the forest for the trees or whatever.
Thanks!
React is (citing their page)
a javascript library for building user interfaces
The main focus is to build a view layer for your application. This means you have full freedom in choosing what to use to fetch your data. For simple uses it can be jQuery or fetch.
It's generally recommended to not fetch data directly in your components and use one of Flux pattern implementations, e.g. Redux.
If your application has to be constantly powered by new data from server you can think about using something like RethinkDB on your backend and connect it to Flux store on your frontend.

history.js and angular or ember

URLs shall be without hashbang
It shall fall back for older Browsers which don't support the History API
Using Angular or Ember
Question: Is there a need to use the history.js?
If yes, read on.
On teamwork.com or soundcloud or other modern websites there is a mechanism to have links loading just a part of the website and at the same time, the URL changes (there is no hashbang). I want to implement this as well and also want to support older browsers and read that history.js can do this. Here is a related question to this where I found that this uses the History Api.
At the same time I want to uses Angular or Ember. I know they have their own routing and there is for example a tutorial to remove the # here.
I read that the different browsers handle the history api differently and that the history.js is a way how to tackle this issue.
So is there a way how to combine those front-end frameworks with that api? I'd start somewhere in the routing but get stuck thinking about what to do...
A new implementation should have cross-browser compatibility including handling older browsers. On one hand I want to have a front end framework to separate front from the backend, not sure about which one to use, yet. On the other hand I like how i.e. teamwork.com handle links that they only load a part of a page (including an animation) when you click on it. At the same time the URL changes and if you type a URL directly the page is loaded correctly. It seems that they do it with jQuery.. not quite sure.
Anyone knows how to use both, routing and the history.js?
I would just use AngularJS with UI Router. It combines routing with history.js like features. It has a HTML5 mode which you can enable which will allow pages to update via AJAX without the use of a hash #.
It should automatically cope with older browsers and change the URL format accordingly.

Resources