Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadn authored Dec 10, 2020
1 parent 386f711 commit d111188
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
### javascript-sdk

Two branches are created one for js-sdk-common and one for js-client-sdk in a single repo. Download the code

1. Go to js-client-sdk directory and run 'npm link path-to-js-sdk-common-dir'

2. Go to your project directory and run 'npm link path-to-js-client-sdk-dir'

3. In your project directory run 'npm install'

4. Import js-client-sdk in your project

```javascript
import * as LDClient from "js-client-sdk";
```

5. Create user object for which flags needs to be evaluated

```javascript
var user = {
"key": "abcd343",
"country": "US"
};
```

6. Add flag keys in options to initialize client object with flags

```javascript
var options = {

flagKeys: ["js-flag"]

}
```

7. Provide browser-client-id that starts with 'test-client' as first argument in initialize and user and options object

```javascript
var ldclient = LDClient.initialize('test-client-*************', user, options);
```

8. Wait for the client to get ready

```javascript
ldclient.on('ready', function() {

var jsFlag = ldclient.variation("js-flag", 'off');

if (jsFlag == 'on') {

console.log("Hello. Js Flag is on");

} else {

console.log("Hello. Js Flag is off");

}
```

0 comments on commit d111188

Please sign in to comment.