Skip to content

Commit a8dd04b

Browse files
committed
update: README.md
1 parent 69a1f13 commit a8dd04b

File tree

1 file changed

+51
-15
lines changed

1 file changed

+51
-15
lines changed

README.md

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ In this guide we explain how to use feature toggles in a JavaScript application
3838

3939
First, install the FeatureProbe SDK as a dependency in your application.
4040

41+
NPM:
42+
4143
```js
4244
npm install featureprobe-client-sdk-js --save
4345
```
@@ -52,14 +54,32 @@ Or via CDN:
5254

5355
After you install and import the SDK, create a single, shared instance of the FeatureProbe sdk.
5456

57+
NPM:
58+
5559
```js
56-
const user = new featureProbe.FPUser("user");
57-
user.with("key", "value");
60+
const uniqueUserId = /* uniqueUserId */;
61+
const user = new FPUser(uniqueUserId);
62+
user.with("userId", /* userId */);
63+
64+
const fp = new FeatureProbe({
65+
remoteUrl: "https://127.0.0.1:4007",
66+
clientSdkKey: /* clientSdkKey */
67+
user,
68+
});
69+
fp.start();
70+
```
71+
72+
Or via CDN:
73+
74+
```js
75+
const uniqueUserId = /* uniqueUserId */;
76+
const user = new featureProbe.FPUser(uniqueUserId);
77+
user.with("userId", /* userId */);
5878

5979
const fp = new featureProbe.FeatureProbe({
60-
remoteUrl: "https://127.0.0.1:4007",
61-
clientSdkKey: '#YOUR-CLIENT-SDK-KEY#',
62-
user,
80+
remoteUrl: "https://127.0.0.1:4007",
81+
clientSdkKey: /* clientSdkKey */
82+
user,
6383
});
6484
fp.start();
6585
```
@@ -69,27 +89,43 @@ fp.start();
6989
You can use sdk to check which value this user will receive for a given feature flag.
7090

7191
```js
72-
fp.on('ready', function() {
73-
const result = fp.boolValue('ui_demo_toggle', false);
74-
if (result) {
75-
do_some_thing();
76-
} else {
77-
do_other_thing();
78-
}
79-
const reason = fp.boolDetail('ui_demo_toggle', false);
80-
console.log(reason);
92+
fp.on("ready", function() {
93+
const result = fp.boolValue(/* toggleKey */, false);
94+
if (result) {
95+
do_some_thing();
96+
} else {
97+
do_other_thing();
98+
}
99+
const reason = fp.boolDetail(/* toggleKey */, false);
100+
console.log(reason);
81101
})
82102
```
83103

84104
### Step 4. Unit Testing (Optional)
105+
NPM:
85106

86107
```js
87108
test("feature probe unit testing", (done) => {
88109
let fp = FeatureProbe.newForTest({ testToggle: true });
89110
fp.start();
90111

91112
fp.on("ready", function () {
92-
let t = fp.boolValue("testToggle", false);
113+
let t = fp.boolValue(/* toggleKey */, false);
114+
expect(t).toBe(true);
115+
done();
116+
});
117+
});
118+
```
119+
120+
Or via CDN:
121+
122+
```js
123+
test("feature probe unit testing", (done) => {
124+
let fp = featureProbe.FeatureProbe.newForTest({ testToggle: true });
125+
fp.start();
126+
127+
fp.on("ready", function () {
128+
let t = fp.boolValue(/* toggleKey */, false);
93129
expect(t).toBe(true);
94130
done();
95131
});

0 commit comments

Comments
 (0)