npm

@incognitus/client-web-core
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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}',
});
Key Description
tenantId Your tenant id
applicationId The 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

Method Description
IncognitusService.initialize(config) Initializes the service (must be called first)
IncognitusService.instance The 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

Package Sidebar

Install

npm i @incognitus/client-web-core

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

20.8 kB

Total Files

14

Last publish

Collaborators

  • stummej
  • incognitus-admin