noibu-feature-flag
v0.1.2
Published
Noibu Feature Flag provider package based on OpenFeature web SDK.
Downloads
447
Readme
noibu-feature-flag
Standalone Noibu Feature Flag package for browser apps, based on OpenFeature Web SDK and GO Feature Flag web provider.
Install
npm install noibu-feature-flagUsage
import {
NoibuFeatureFlag,
NoibuFeatureFlagProvider,
NoibuProviderEvents,
type NoibuEvaluationContext
} from "noibu-feature-flag";
const context: NoibuEvaluationContext = {
targetingKey: "user-id",
attributes: { test: 12345 }
};
const provider = new NoibuFeatureFlagProvider({
endpoint: "https://your-feature-flag-endpoint/",
apiKey: "your-api-key",
maxRetries: 5,
dataFlushInterval: 5 * 60 * 1000,
apiTimeout: 1000
});
await NoibuFeatureFlag.setContext(context);
NoibuFeatureFlag.setProvider(provider);
const client = NoibuFeatureFlag.getClient("www.example.com");
client.addHandler(NoibuProviderEvents.Ready, () => {
console.log(client.getBooleanValue("my-flag", false));
});Scripts
npm run buildbuilds ESM/CJS outputs and type declarations intodist.npm run lintruns ESLint forsrc.
