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
expect(getClient(splitSdk).evalOnReady.length).toEqual(0);// control assertion - no evaluations were registered for SDK_READY on main client
544
540
expect(getClient(splitSdk,'other-user-key').evalOnReady.length).toEqual(1);// control assertion - 1 evaluation was registered for SDK_READY on the new client
// and an ADD_TREATMENTS action is dispatched with control treatments without calling SDK client.
548
-
action=store.getActions()[1];
543
+
// If SDK was ready from cache, the SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS action is dispatched for the new clients, calling SDK client to evaluate from cache
expect(store.getActions().length).toBe(7);// control assertion - no more actions after the update.
635
-
expect(splitSdk.factory.client('other-user-key').getTreatmentsWithConfig).toBeCalledTimes(4);// control assertion - called 4 times, in actions SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS, SPLIT_READY_WITH_EVALUATIONS, SPLIT_UPDATE_WITH_EVALUATIONS and ADD_TREATMENTS.
633
+
expect(store.getActions().length).toBe(8);// control assertion - no more actions after the update.
634
+
expect(splitSdk.factory.client('other-user-key').getTreatmentsWithConfig).toBeCalledTimes(5);// control assertion - called 5 times, in actions SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS, SPLIT_READY_WITH_EVALUATIONS, ADD_TREATMENTS, SPLIT_UPDATE_WITH_EVALUATIONS and ADD_TREATMENTS.
Copy file name to clipboardExpand all lines: src/asyncActions.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -148,6 +148,7 @@ export function getTreatments(params: IGetTreatmentsParams): Action | (() => voi
148
148
client.evalOnReady.push(params);
149
149
}
150
150
151
+
// @TODO breaking: consider removing `evalOnReadyFromCache` config option, since `false` value has no effect on shared clients (they are ready from cache immediately) and on the main client if its ready from cache when `getTreatments` is called
151
152
// If the SDK is not ready from cache and flag `evalOnReadyFromCache`, it stores the action to execute when ready from cache
// Shared clients might be ready from cache immediately, so we need to dispatch a single action that updates treatments and `isReadyFromCache` status atomically
162
+
// @TODO handle this corner case by refactoring actions into a single action that includes both the client status and optional evaluation/s, to minimize state changes and avoid edge cases
0 commit comments