All Projects â†’ pinguet62 â†’ vue-feature-flipping

pinguet62 / vue-feature-flipping

Licence: Apache-2.0 license
"Feature flipping" plugin for Vue.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-feature-flipping

featurehub
FeatureHub - cloud native feature flags, A/B testing and remote configuration service. Real-time streaming feature updates. Provided with Java, JavaScript, Go, .Net, Android and Flutter SDKs.
Stars: ✭ 136 (+615.79%)
Mutual labels:  feature-toggle, feature-flag, feature-flipping
Flipper
đŸŦ Beautiful, performant feature flags for Ruby.
Stars: ✭ 2,732 (+14278.95%)
Mutual labels:  feature-toggle, feature-flag
flagsmith-js-client
Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 42 (+121.05%)
Mutual labels:  feature-toggle, feature-flag
js-sdk
JavaScript frontend SDK for ConfigCat. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
Stars: ✭ 21 (+10.53%)
Mutual labels:  feature-toggle, feature-flag
ld-redux
A library to integrate launch darkly with react redux
Stars: ✭ 33 (+73.68%)
Mutual labels:  feature-toggle, feature-flag
ld-scheduler
Schedule Launch Darkly flags on or off
Stars: ✭ 14 (-26.32%)
Mutual labels:  feature-toggle, feature-flag
Unleash
Unleash is the open source feature toggle service.
Stars: ✭ 4,679 (+24526.32%)
Mutual labels:  feature-toggle
nestjs-unleash
Unleash feature toggle support for NestJS
Stars: ✭ 31 (+63.16%)
Mutual labels:  feature-toggle
toggler
toggler is a feature flag service to decouple deployment, feature enrollment and experiments
Stars: ✭ 27 (+42.11%)
Mutual labels:  feature-toggle
FeatureSwitch
FeatureSwitch is library that should reduce amount of time and code required to implement feature switching in your projects.
Stars: ✭ 54 (+184.21%)
Mutual labels:  feature-toggle
eight ball
Ruby gem for querying feature flags
Stars: ✭ 17 (-10.53%)
Mutual labels:  feature-toggle
vue-feature-toggle
No description or website provided.
Stars: ✭ 55 (+189.47%)
Mutual labels:  feature-toggle
flagsmith-java-client
Java Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 16 (-15.79%)
Mutual labels:  feature-flag
muton
A feature toggle tool with support for feature throttling and multivariance testing.
Stars: ✭ 15 (-21.05%)
Mutual labels:  feature-toggle
doorkeeper
A Feature Toggle for PHP
Stars: ✭ 16 (-15.79%)
Mutual labels:  feature-toggle
flipper
Feature Flipper, Feature Flags, Rollout Flags, Feature Toggles for Crystal
Stars: ✭ 21 (+10.53%)
Mutual labels:  feature-flag
php-client
PHP SDK client for Split Software
Stars: ✭ 14 (-26.32%)
Mutual labels:  feature-toggle
teg
Teg is a library for managing feature toggles. It aims to allow to create and access to feature toggles in Golang easily and quickly!
Stars: ✭ 23 (+21.05%)
Mutual labels:  feature-toggle
laravel-rollout
A package to integrate rollout into your Laravel project.
Stars: ✭ 23 (+21.05%)
Mutual labels:  feature-toggle
ruby-client
Ruby SDK client for Split Software
Stars: ✭ 22 (+15.79%)
Mutual labels:  feature-toggle

vue-feature-flipping

ℹī¸ Vue 3 supported!

Maintained

Codacy Badge Codacy Badge

GitHub Actions

Demo Badge

Vue.js plugin providing a set of components used to introduce "feature flipping" in your project.

Why use this plugin?

The build of the application packaged into bundle the configuration file (config/*.env.js constants) and environment variables (process.env.* usages). So to modify any value, you have to re-build the application.

When you have to enable or disable a feature, the update must be easy and instantaneous.

This plugin solve this problem.

How it works?

All feature flags (list of keys of type string) are stored into plugin.
This list is dynamically initialized at startup (by setEnabledFeatures() function).
Components use this list to define if action can be done (DOM can be shown, route is accessible, ...).

Configuration

1. NPM module

Install NPM dependency:

npm install --save vue-feature-flipping

2. Plugin registration

Register all Vue.js components (directive, guard, ...) calling .use():

import Vue from 'vue'
import FeatureFlipping from 'vue-feature-flipping'

createApp(...)
  .use(FeatureFlipping)
  .mount(...)

3. Features list registration

The setEnabledFeatures(string[]) function can be used to define the feature list.

import { setEnabledFeatures } from 'vue-feature-flipping'

setEnabledFeatures(['FF1', 'FF2', 'FF3'])

You can dynamically refresh the list, using socket.io or setInterval like this example:

setInterval(
    async () => setEnabledFeatures(await getFeaturesFromBackend('http://localhost:8081')),
    60000
)

Usage

Service

A function is defined to check a feature.
If the feature is not enabled, the function returns false.

import { isEnabled } from 'vue-feature-flipping'

if (isEnabled('XXXXX')) {
    // ...
}

if (isEnabled('XXXXX', true)) {
    // ...
}

Directive

A directive named feature-flipping can be used into <template>.

Rendering

Without argument, the directive works like v-if. If the feature is not enabled, the DOM is removed.

<menu>
    <entry>First</entry>
    <entry v-feature-flipping="'XXXXX'">Second</entry>
    <entry v-feature-flipping.not="'XXXXX'">Third</entry>
    <entry v-feature-flipping.default="'XXXXX'">Fourth</entry>
</menu>
Class

The argument class allow the directive to work like v-bind:class. If the feature is enabled, the classes are apply to element.

<menu>
    <entry>First</entry>
    <entry v-feature-flipping:class="{ key: 'XXXXX', value: 'class1' }">Second</entry>
    <entry v-feature-flipping:class="{ key: 'XXXXX', value: ['class1', ['class2'], { 'class3': true }] }">Third</entry>
    <entry v-feature-flipping:class.not="{ key: 'XXXXX', value: 'class1' }">Fourth</entry>
    <entry v-feature-flipping:class.default="{ key: 'XXXXX', value: 'class1' }">Fifth</entry>
</menu>
Style

The argument style allow the directive to work like v-bind:style. If the feature is enabled, the styles are apply to element.

<menu>
    <entry>First</entry>
    <entry v-feature-flipping:style="{ key: 'XXXXX', value: { style1: 'value1', style2: 'value2' } }">Second</entry>
    <entry v-feature-flipping:style="{ key: 'XXXXX', value: [{ style1: 'value1' }, { style2: 'value2' }] }">Third</entry>
    <entry v-feature-flipping:style.not="{ key: 'XXXXX', value: { style1: 'value1' } }">Fourth</entry>
    <entry v-feature-flipping:style.default="{ key: 'XXXXX', value: { style1: 'value1' } }">Fifth</entry>
</menu>

Route

A guard is defined to intercept all routes defining featureFlipping meta field.
If the feature is not enabled, the router redirect to "/" route.

import VueRouter from 'vue-router'
import { Test1Component, Test2Component, Test3Component } from '...'

createRouter({
    routes: [
        { path: '/test1', component: Test1Component, meta: { featureFlipping: { key: 'XXXXX' } } },
        { path: '/test2', component: Test2Component, meta: { featureFlipping: { key: 'XXXXX' }, redirect: '/error' } },
        { path: '/test3', component: Test3Component, meta: { featureFlipping: { key: 'XXXXX', not: true } } },
        { path: '/test4', component: Test4Component, meta: { featureFlipping: { key: 'XXXXX', default: true } } },
    ]
})

Options

default: default behavior

When the plugin is not initialized, or when any error occurs when user try to initialize this plugin, it's necessary to define a default behavior: should we activate the function or should we disable it?

The default value defines this behavior: the value is used when plugin is not initialized or initialized with null.

Example:

try {
    let features = await getFeaturesFromBackend()
    setEnabledFeatures(features)
} catch (e) {
    setEnabledFeatures(null) // use default
}

not: reversed rendering

In some cases, we have to define a behavior when the feature is disabled.

The not option activate this behavior.

Best practices

  • Independent - Avoid behavior depending multiples features.
    Bad: if (isEnabled('F1') && isEnabled('F2') || isEnabled('F3')) ...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].