@nosnibor89/svelte-client-sdk 0.1.25 → 0.1.27

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.
@@ -16,8 +16,6 @@
16
16
  $effect(() => {
17
17
  console.log('[LDFlag] flag changed', $flagValue)
18
18
  })
19
-
20
-
21
19
  </script>
22
20
 
23
21
  {#if $flagValue === matches}
@@ -8,7 +8,7 @@ export type LDClientID = string;
8
8
  export type LDFlags = LDFlagSet;
9
9
  /** The LaunchDarkly instance */
10
10
  export declare const LD: {
11
- identify: (context: LDContext) => Promise<any>;
11
+ identify: (context: LDContext) => Promise<LDFlagSet>;
12
12
  flags: Readable<LDFlagSet>;
13
13
  initialize: (clientId: LDClientID, context: LDContext, options?: LDOptions) => {
14
14
  initializing: Writable<boolean>;
@@ -42,6 +42,7 @@ function toFlagsProxy(client, flags) {
42
42
  * @returns {Object} The LaunchDarkly instance object.
43
43
  */
44
44
  function createLD() {
45
+ console.log('instantiating client');
45
46
  let coreLdClient;
46
47
  const loading = writable(true);
47
48
  const flagsWritable = writable({});
@@ -57,12 +58,14 @@ function createLD() {
57
58
  coreLdClient.on('ready', () => {
58
59
  loading.set(false);
59
60
  const rawFlags = coreLdClient.allFlags();
61
+ // coreLdClient;
60
62
  // const allFlags = toFlagsProxy(coreLdClient!, rawFlags);
61
63
  const allFlags = rawFlags;
62
64
  console.log('[LD] flag ready', rawFlags, allFlags);
63
65
  flagsWritable.set(allFlags);
64
66
  });
65
- coreLdClient.on('change', () => {
67
+ coreLdClient.on('change', (context, changedFlags) => {
68
+ console.log('changed ctx', context, changedFlags);
66
69
  const rawFlags = coreLdClient.allFlags();
67
70
  // const allFlags = toFlagsProxy(coreLdClient!, rawFlags);
68
71
  const allFlags = rawFlags;
@@ -80,7 +83,10 @@ function createLD() {
80
83
  */
81
84
  async function identify(context) {
82
85
  isClientInitialized(coreLdClient);
83
- return coreLdClient.identify(context);
86
+ const allFlags = await coreLdClient.identify(context);
87
+ // const allFlags = toFlagsProxy(coreLdClient!, rawFlags);
88
+ flagsWritable.set(allFlags);
89
+ return allFlags;
84
90
  }
85
91
  /**
86
92
  * Watches a flag for changes.
@@ -15,6 +15,7 @@
15
15
  const { initialize, initializing: isClientInitializing } = LD;
16
16
 
17
17
  onMount(() => {
18
+ console.log('mounting provider', context)
18
19
  initialize(clientID, context, options);
19
20
  });
20
21
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosnibor89/svelte-client-sdk",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Svelte LaunchDarkly SDK",
5
5
  "homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/svelte",
6
6
  "repository": {