1.0.1 • Published 4 years ago

@incognitus/client-web-core v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Incognitus Feature Flag (web core)

Continuous Integration codecov npm version

Integrating Incognitus

Initializing the service

Before you're able to use the service you'll need to initialize with your tenant and application IDs.

index.ts

Initialize Incognitus service

import { IncognitusService } from '@incognitus/client-web-core';

const IncognitusService.initialize({
  tenantId: '{your tenant key}',
  applicationId: '{your app id}',
});
KeyDescription
tenantIdYour tenant id
applicationIdThe id of the application

Checking features

import { IncognitusService } from '@incognitus/client-web-core';

const svc = IncognitusService.instance;

const foobar = async () => {
  if (await svc.isEnabled('{feature name}')) {
    return 'new feature text';
  }
  return 'old feature text';
};

Methods

MethodDescription
IncognitusService.initialize(config)Initializes the service (must be called first)
IncognitusService.instanceThe shared instance of the service
svc.isEnabled(featureName)Checks if the flag is enabled
svc.isDisabled(featureName)Check if the flag is disabled
svc.getFeature(featureName)Fetches the feature from the server and returns it's status
svc.getAllFeatures()Fetches all features and stores them in the cache

Caching

Currently all known feature flags are cached when the app initializes. New features that are not found in the cache are retrieved on-demand. The cache stays in place until the app is reloaded or by calling the getAllFeatures() method on the service.

Future Caching Stories

  • Save verified cache to local storage
  • Provide hard cache refresh (wipe cache if fails)
  • Provide soft cache refresh (keep cache if fails)
  • Customizable cache refresh times
  • Option to disable cache