You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/sdk/browser/upgrade/v4.md
+49-3Lines changed: 49 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,12 @@ successfully upgrade.
13
13
14
14
## Key changes
15
15
16
-
### Client creation
16
+
### Client initialization
17
17
18
18
**Key differences:**
19
19
- Initialization is now split into 2 parts `createClient` and `start`
20
+
- We split the original `LDOptions` that was passed into the `initialize()` function into
21
+
2 types `LDStartOptions` and `LDOptions`. [more here](#ldoptions)
20
22
- Removed the use of `initialize` method
21
23
22
24
**Before (v3.x):**
@@ -43,6 +45,21 @@ perform any necessary setup before the client begins connecting to LaunchDarkly.
43
45
This eliminates race conditions where events might be missed if listeners were
44
46
registered after the client had already started initializing.
45
47
48
+
### LDOptions
49
+
50
+
We moved a few things around in `LDOptions` to support the changes that are discussed in
51
+
other parts of this doc. Please visit the following docs to see how to interact with our SDK:
52
+
-[LDOptions](https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDOptions.html) that is passed into `createClient()`
53
+
-[LDStartOptions](https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDStartOptions.html) that is passed into `start()`
54
+
-[LDIdentifyOptions](https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDIdentifyOptions.html) that is passed into `identify()`
55
+
56
+
**Key differences:**
57
+
-`bootstrap` option is moved from `LDOptions` to `LDStartOptions` and `Identify`. The reason for this is that bootstrapping data is
58
+
now part of the initialization of a client instance.
59
+
> NOTE: that `identify` is a key part of the client initialization process required to associate the instance with an initial context.
60
+
- The SDK now defaults to use local storage based caching.
61
+
> Previously, in order enable local storage caching, you will need to set this as a special value for the `bootstrap` property.
62
+
46
63
### Client initialization flow
47
64
48
65
The new SDK uses `waitForInitialization()` which returns a result object instead of rejecting promises.
@@ -111,11 +128,15 @@ The `identify()` method now always returns a result object and never throws erro
111
128
This provides more predictable error handling.
112
129
113
130
**Key differences:**
114
-
-`identify()` now takes an options object as the second parameter: `{ hash: '...' }` instead of a direct hash string
131
+
-`identify()` now takes an options object as the second parameter: `LDIdentifyOptions` instead of a direct hash string
115
132
- The method always returns a promise that resolves to a result object (never rejects)
116
133
- You must check the `status` field to determine success or failure
117
134
- The `hash` parameter is now part of the options object
135
+
-`IdentifyOptions` now have a `sheddable` property that is `true` by default. Which means the default behavior for
136
+
multiple identify calls is different
137
+
[more info here](https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDIdentifyOptions.html#sheddable)
118
138
- Callback support has been removed - use async/await or `.then()` instead
139
+
> See [options section](#ldoptions) for more information about changes to the options.
119
140
120
141
**Before (v3.x):**
121
142
```javascript
@@ -154,7 +175,7 @@ if (result.status === 'completed') {
154
175
}
155
176
```
156
177
157
-
### Flag change event
178
+
### Flag change event payload
158
179
159
180
The `change` event now receives the context and an array of changed flag keys as parameters.
160
181
> NOTE: we will no longer return the flag value object along with this event
0 commit comments