Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 92301c7

Browse files
committed
update read example to use ready event
1 parent cef5b39 commit 92301c7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ Quick setup
1717

1818
2. Create a new LDClient with your API key:
1919

20-
ld_client = LaunchDarkly.init("YOUR API KEY")
20+
var ld_client = LaunchDarkly.init("YOUR API KEY")
2121

2222
Your first feature flag
2323
-----------------------
2424

2525
1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com)
2626
2. In your application code, use the feature's key to check whether the flag is on for each user:
27-
28-
ld_client.toggle("your.flag.key", {"key" : "[email protected]"}, false, function(err, show_feature) {
29-
if (show_feature) {
30-
# application code to show the feature
31-
}
32-
else {
33-
# the code to run if the feature is off
34-
}
27+
28+
ld_client.once('ready', function() {
29+
ld_client.toggle("your.flag.key", {"key" : "[email protected]"}, false, function(err, show_feature) {
30+
if (show_feature) {
31+
# application code to show the feature
32+
}
33+
else {
34+
# the code to run if the feature is off
35+
}
36+
});
3537
});
3638

3739

@@ -68,4 +70,3 @@ About LaunchDarkly
6870
* [docs.launchdarkly.com] (http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs
6971
* [apidocs.launchdarkly.com] (http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
7072
* [blog.launchdarkly.com] (http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
71-

0 commit comments

Comments
 (0)