@nosnibor89/svelte-client-sdk 0.1.291 → 0.1.293
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -14
- package/package.json +1 -1
package/README.md
CHANGED
@@ -26,17 +26,21 @@ Then, initialize the SDK with your client-side ID using the `LDProvider` compone
|
|
26
26
|
<script>
|
27
27
|
import { LDProvider } from '@launchdarkly/svelte-client-sdk';
|
28
28
|
import App from './App.svelte';
|
29
|
-
</script>
|
30
29
|
|
31
|
-
// Use context relevant to your application
|
32
|
-
const context = {
|
33
|
-
|
30
|
+
// Use context relevant to your application
|
31
|
+
const context = {
|
32
|
+
kind: 'user',
|
34
33
|
key: 'user-key',
|
35
|
-
|
36
|
-
|
34
|
+
};
|
35
|
+
</script>
|
37
36
|
|
38
37
|
<LDProvider clientID="your-client-side-id" {context}>
|
39
|
-
|
38
|
+
<!-- Optional initializing snippet in case you want to render something else while LD client initializes -->
|
39
|
+
{#snippet initializing()}
|
40
|
+
<p>loading flags...</p>
|
41
|
+
{/snippet}
|
42
|
+
|
43
|
+
<App />
|
40
44
|
</LDProvider>
|
41
45
|
```
|
42
46
|
|
@@ -48,12 +52,12 @@ Now you can use the `LDFlag` component to conditionally render content based on
|
|
48
52
|
</script>
|
49
53
|
|
50
54
|
<LDFlag flag={'my-feature-flag'}>
|
51
|
-
|
55
|
+
{#snippet on()}
|
52
56
|
<p>this will render if the feature flag is on</p>
|
53
|
-
|
54
|
-
|
57
|
+
{/snippet}
|
58
|
+
{#snippet off()}
|
55
59
|
<p>this will render if the feature flag is off</p>
|
56
|
-
|
60
|
+
{/snippet}
|
57
61
|
</LDFlag>
|
58
62
|
```
|
59
63
|
|
@@ -68,11 +72,11 @@ You can change the user context by using the `identify` function from the `LD` o
|
|
68
72
|
import { LD } from '@launchdarkly/svelte-client-sdk';
|
69
73
|
|
70
74
|
function handleLogin() {
|
71
|
-
LD.identify({ key: 'new-user-key' });
|
75
|
+
LD.identify({ kind: 'user', key: 'new-user-key' });
|
72
76
|
}
|
73
77
|
</script>
|
74
78
|
|
75
|
-
<button
|
79
|
+
<button onclick={handleLogin}>Login</button>
|
76
80
|
```
|
77
81
|
|
78
82
|
### Getting feature flag values
|
@@ -91,7 +95,7 @@ If you need to get the value of a flag at time of evaluation you can use the `us
|
|
91
95
|
}
|
92
96
|
</script>
|
93
97
|
|
94
|
-
<button
|
98
|
+
<button onclick={handleClick}>Check flag value</button>
|
95
99
|
```
|
96
100
|
|
97
101
|
**Note:** Please note that `useFlag` function will return the current value of the flag at the time of evaluation, which means you won't get notified if the flag value changes. This is useful for cases where you need to get the value of a flag at a specific time like a function call. If you need to get notified when the flag value changes, you should use the `LDFlag` component, the `watch` function or the `flags` object depending on your use case.
|
package/package.json
CHANGED