Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blaze/toggles

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blaze/toggles

Open Source UI Toolkit - Feature Toggles

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by750%
Maintainers
1
Weekly downloads
 
Created
Source

Blaze Feature Toggles

Blaze is a framework-free open source UI toolkit. It provides great structure for building websites quickly with a scalable and maintainable foundation.

https://www.blazeui.com

ci build status

Using the Toggles

Add the following to your <head></head>.

<script src="https://unpkg.com/@blaze/toggles@x.x.x/dist/collection/config.js"></script>
<script src="https://unpkg.com/@blaze/toggles@x.x.x/dist/toggles.js"></script>

The x.x.x is the specific version of the library, you should use specifc versions to prevent against breaking changes.

Config

Next add some feature toggle config, e.g.

FeatureToggles.set({
  welcomeMessage: true,
  loginPage: {
    rememberMe: 'alpha',
  },
});

You can call FeatureToggles.set({...}) at anytime to update config. Everytime FeatureToggles.set is called it raises a featureToggleChange event that you can hook into.

set also merges the config with the already set config.

Config values can be either booleans, strings or functions.

Promises are supported.

e.g. the below to toggle the feature after 2 seconds once the promise has resolved.

FeatureToggles.set({
  welcomeMessage: true,
  loginPage: {
    rememberMe: () => new Promise((resolve) => setTimeout(() => resolve('alpha'), 2000)),
  },
});

HTML

<feature-toggle feature="welcomeMessage">
  content will be VISIBLE
</feature-toggle>

<feature-toggle feature="loginPage.rememberMe" variant="alpha">
  content will be VISIBLE
</feature-toggle>

<feature-toggle feature="loginPage.rememberMe" variant="beta">
  content will be HIDDEN
</feature-toggle>
SettingDescription
featureFeature config item, supports dot notation
variantThe value the toggle must be to turn on this feature (default: true)

Keywords

FAQs

Package last updated on 29 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc