Skip to content

Commit a8793e9

Browse files
committed
cleanup readme and example
1 parent 357943e commit a8793e9

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ const launchdarkly = new LaunchDarkly(components.launchdarkly);
121121
export const myQuery = query({
122122
args: {},
123123
handler: async ({ ctx }) => {
124-
const launchdarkly = ld.sdk(ctx);
125-
const isFlagOn = await launchdarkly.boolVariation(
124+
const ld = launchdarkly.sdk(ctx);
125+
const isFlagOn = await ld.boolVariation(
126126
"my-flag",
127127
{ key: "myUser" },
128128
false
@@ -204,20 +204,20 @@ Once configured, you may initialize `LaunchDarkly` with the appropriate componen
204204
```typescript
205205
import { LaunchDarkly } from "@convex-dev/launchdarkly";
206206

207-
const ldFirst = new LaunchDarkly(components.first, {
207+
const launchDarklyFirst = new LaunchDarkly(components.first, {
208208
LAUNCHDARKLY_SDK_KEY: process.env.LAUNCHDARKLY_SDK_KEY_FIRST!,
209209
});
210210

211-
const ldSecond = new LaunchDarkly(components.second, {
211+
const launchDarklySecond = new LaunchDarkly(components.second, {
212212
LAUNCHDARKLY_SDK_KEY: process.env.LAUNCHDARKLY_SDK_KEY_SECOND!,
213213
});
214214

215215
export const myQuery = query({
216216
args: {},
217217
handler: async ({ ctx }) => {
218-
const launchdarklyFirst = ldFirst.sdk(ctx);
218+
const ldFirst = launchdarklyFirst.sdk(ctx);
219219

220-
const launchdarklySecond = ldSecond.sdk(ctx);
220+
const ldSecond = launchDarklySecond.sdk(ctx);
221221

222222
...
223223
},

example/convex/example.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ const launchdarkly = new LaunchDarkly(components.launchdarkly);
66

77
export const listFruits = query({
88
handler: async (ctx) => {
9-
const ld= = launchdarkly.sdk(ctx);
9+
const ld = launchdarkly.sdk(ctx);
1010
const user = { key: "myUserId" };
1111

12-
const showFruits = await ld.boolVariation(
13-
"can-show-fruits",
14-
user,
15-
true
16-
);
12+
const showFruits = await ld.boolVariation("can-show-fruits", user, true);
1713
if (!showFruits) {
1814
return [];
1915
}
@@ -27,11 +23,7 @@ export const buyFruit = mutation({
2723

2824
const user = { key: "myUserId" };
2925

30-
const showFruits = await ld.boolVariation(
31-
"can-buy-fruits",
32-
user,
33-
false
34-
);
26+
const showFruits = await ld.boolVariation("can-buy-fruits", user, false);
3527
if (!showFruits) {
3628
return {
3729
error:
@@ -51,9 +43,8 @@ export const initialized = query({
5143
}
5244
const ld = launchdarkly.sdk(ctx);
5345
return (
54-
(await ld.allFlagsState({ key: "any" })).allValues()[
55-
"can-buy-fruits"
56-
] !== undefined
46+
(await ld.allFlagsState({ key: "any" })).allValues()["can-buy-fruits"] !==
47+
undefined
5748
);
5849
},
5950
});

0 commit comments

Comments
 (0)