mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Always use forceConsistentCasingInFileNames * Rename files * Convert more packages to `types-2.0` style
31 lines
745 B
TypeScript
31 lines
745 B
TypeScript
// Implicitly calls LDClient#identify
|
|
const ldClient = LDClient.initialize(
|
|
'ENV KEY',
|
|
{
|
|
key: 'USER KEY',
|
|
name: 'USER NAME',
|
|
custom: {
|
|
'CUSTOM ATTRIBUTE': ['CUSTOM VALUE'],
|
|
},
|
|
},
|
|
{
|
|
hash: 'SECURE USER HASH',
|
|
}
|
|
);
|
|
|
|
ldClient.on('ready', () => {
|
|
const defaultValue = false;
|
|
ldClient.variation('FLAG-KEY', defaultValue);
|
|
console.log('All flag values:', ldClient.allFlags());
|
|
});
|
|
|
|
function changeCallback(changes: LaunchDarkly.LDFlagChangeset) {
|
|
console.log('Flags changed:', changes);
|
|
}
|
|
|
|
ldClient.on('change', changeCallback);
|
|
|
|
document.getElementById('disable-change-tracking')!.addEventListener('click', () => {
|
|
ldClient.off('change', changeCallback);
|
|
});
|