@storyous/features
v4.0.3
Published
## Usage
Maintainers
Keywords
Readme
features
Usage
import { Features } from '@storyous/features';
// cache initialization
const instance = new Features();
instance.init({
baseUrl, // url of featureService
globalQueryParams, // query params to featureService {environment: test}
ttl, // lifetime of cache, default 1 minute
fetchTimeout, // default 20000 ms
databaseCache, // optional field for persisting cache in database, if ommited, data are cached only in memory
});
// check if feature is enabled
await instance.enabled(
"choice",
{ merchantId: "639c81da83c2c20709c84fab" }, // aditional query parameters
{
fallBackValue: true, // default value if there is a error during fetching feature and there is no value in cache yet
timeout: 5000, // timeout for fetching feature from service, default 2000 ms
}, // boolean or "error"
)
...
