Skip to content

Commit d111188

Browse files
authored
Create README.md
1 parent 386f711 commit d111188

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
### javascript-sdk
2+
3+
Two branches are created one for js-sdk-common and one for js-client-sdk in a single repo. Download the code
4+
5+
1. Go to js-client-sdk directory and run 'npm link path-to-js-sdk-common-dir'
6+
7+
2. Go to your project directory and run 'npm link path-to-js-client-sdk-dir'
8+
9+
3. In your project directory run 'npm install'
10+
11+
4. Import js-client-sdk in your project
12+
13+
```javascript
14+
import * as LDClient from "js-client-sdk";
15+
```
16+
17+
5. Create user object for which flags needs to be evaluated
18+
19+
```javascript
20+
var user = {
21+
"key": "abcd343",
22+
"country": "US"
23+
};
24+
```
25+
26+
6. Add flag keys in options to initialize client object with flags
27+
28+
```javascript
29+
var options = {
30+
31+
flagKeys: ["js-flag"]
32+
33+
}
34+
```
35+
36+
7. Provide browser-client-id that starts with 'test-client' as first argument in initialize and user and options object
37+
38+
```javascript
39+
var ldclient = LDClient.initialize('test-client-*************', user, options);
40+
```
41+
42+
8. Wait for the client to get ready
43+
44+
```javascript
45+
ldclient.on('ready', function() {
46+
47+
var jsFlag = ldclient.variation("js-flag", 'off');
48+
49+
if (jsFlag == 'on') {
50+
51+
console.log("Hello. Js Flag is on");
52+
53+
} else {
54+
55+
console.log("Hello. Js Flag is off");
56+
57+
}
58+
```

0 commit comments

Comments
 (0)