Skip to content

Commit 2074373

Browse files
authored
Fix description for onReady and setUser (#4)
- onReady is based on both datafile and user availability - setUser can accept a Promise for a User
1 parent 61254dc commit 2074373

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ The following type definitions are used in the `ReactSDKClient` interface:
377377

378378
`ReactSDKClient` instances have the methods/properties listed below. Note that in general, the API largely matches that of the core `@optimizely/optimizely-sdk` client instance, which is documented on the [Optimizely X Full Stack developer docs site](https://docs.developers.optimizely.com/full-stack/docs). The major exception is that, for most methods, user id & attributes are ***optional*** arguments. `ReactSDKClient` has a current user. This user's id & attributes are automatically applied to all method calls, and overrides can be provided as arguments to these method calls if desired.
379379

380-
* `onReady(opts?: { timeout?: number }): Promise` Returns a Promise that fulfills with an object representing the datafile fetch process. See [JavaScript: Update datafiles](https://docs.developers.optimizely.com/full-stack/docs/javascript-update-datafiles)
380+
* `onReady(opts?: { timeout?: number }): Promise` Returns a Promise that fulfills with an object representing the initialization process. The instance is ready when it has fetched a datafile and a user is available (via `setUser` being called with an object, or a Promise passed to `setUser` becoming fulfilled).
381381
* `user: User` The current user associated with this client instance
382-
* `setUser(userInfo: User): void` Call this to update the current user
382+
* `setUser(userInfo: User | Promise<User>): void` Call this to update the current user
383383
* `onUserUpdate(handler: (userInfo: User) => void): () => void` Subscribe a callback to be called when this instance's current user changes. Returns a function that will unsubscribe the callback.
384384
* `activate(experimentKey: string, overrideUserId?: string, overrideAttributes?: UserAttributes): string | null` Activate an experiment, and return the variation for the given user.
385385
* `getVariation(experimentKey: string, overrideUserId?: string, overrideAttributes?: UserAttributes): string | null` Return the variation for the given experiment and user.

0 commit comments

Comments
 (0)