0

How to use Launch Darkly Feature Flags in an Angular Application

 9 months ago
source link: https://blog.bitsrc.io/how-to-use-launch-darkly-feature-flags-in-an-angular-application-84a015fb0d79
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to use Launch Darkly Feature Flags in an Angular Application

Put easy on/off switches around your application’s features

1*z6W2WDQ2jwGKTUOcE-CvRA.png

Overview

In the software world, once your application has reached production and you are still developing new features, you can often find yourself in a situation where you need to hide code from users that is not yet complete. This can occur when your feature is large enough to span multiple stories (think Agile). The completed stories are sent to your Test environment for verification by your QA team, but are not ready for your production environment until the feature (and all its stories) is complete. However, other new features may still need to be deployed to production. It’s this scenario where you should consider using feature flags.

Launch Darkly Feature Flags

Several companies provide feature flags with an API to use them. But for this article, we will focus on Launch Darkly (https://launchdarkly.com/).

Launch Darkly not only lets you target feature flags per environment (Dev, Test, Production, etc.) but also by data about your users that you send to it. This could be email addresses, roles, tenants and more! How to set up your feature flags in Launch Darkly is beyond the scope of this article. Here, we will focus on wiring up your feature flags into an Angular application.

Installation

First, you’ll need to install the Launch Darkly Javascript SDK.

For this article, we will be using the latest JavaScript SDK for Launch Darkly as of November 2023 (v3.1.4).

npm install -SE [email protected]

The Code

First, let’s create an Angular service to manage our feature flags. For this example, we’ll assume we have one feature flag called “Shopping Cart v2”. When you create such a feature flag in Launch Darkly, it will automatically create a slug-cased…


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK