Skip to content

Commit 12a7188

Browse files
authored
chore: improve usage doc, refer to docs (#290)
This adds more usage doc to give a terse API overview. It also adds a link to docs.openefeature.dev, which is where we really want to push people for thorough doc. Signed-off-by: Todd Baert <[email protected]>
1 parent 96fa4d0 commit 12a7188

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,33 @@ yarn add @openfeature/js-sdk
3030
```typescript
3131
import { OpenFeature } from '@openfeature/js-sdk';
3232

33-
OpenFeature.setProvider(new MyProvider());
33+
// configure a provider
34+
OpenFeature.setProvider(new YourProviderOfChoice());
3435

35-
const client = OpenFeature.getClient();
36+
// create a client
37+
const client = OpenFeature.getClient('my-app');
3638

37-
const value = await client.getBooleanValue('enabled-new-feature', false);
39+
// get a bool value
40+
const boolValue = await client.getBooleanValue('boolFlag', false);
41+
42+
// get a string value
43+
const stringValue = await client.getStringValue('stringFlag', 'default');
44+
45+
// get an numeric value
46+
const numberValue = await client.getNumberValue('intFlag', 1);
47+
48+
// get an object value
49+
const object = await client.getObjectValue<MyObject>('objectFlag', {});
50+
51+
// add a value to the invocation context
52+
const context: EvaluationContext = {
53+
myInvocationKey: 'myInvocationValue',
54+
};
55+
const contextAwareValue = await client.getBooleanValue('boolFlag', false, context);
3856
```
3957

58+
For complete documentation, visit: https://docs.openfeature.dev/docs/category/concepts
59+
4060
## Contributing
4161

4262
See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the OpenFeature project.

0 commit comments

Comments
 (0)