From 065c6e0f6c3ef9011c3605e17952ab2ced0c61ef Mon Sep 17 00:00:00 2001 From: Emmanuel Zamora Date: Thu, 2 Nov 2023 14:57:04 -0300 Subject: [PATCH] approach improvement --- package-lock.json | 4 ++-- package.json | 2 +- src/sync/polling/updaters/splitChangesUpdater.ts | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 31eea521..db3d8b54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.1", + "version": "1.10.1-rc.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.1", + "version": "1.10.1-rc.3", "license": "Apache-2.0", "dependencies": { "tslib": "^2.3.1" diff --git a/package.json b/package.json index 5560e64e..2bd2eed9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.1", + "version": "1.10.1-rc.3", "description": "Split Javascript SDK common components", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/sync/polling/updaters/splitChangesUpdater.ts b/src/sync/polling/updaters/splitChangesUpdater.ts index 5f6575b3..583da077 100644 --- a/src/sync/polling/updaters/splitChangesUpdater.ts +++ b/src/sync/polling/updaters/splitChangesUpdater.ts @@ -128,7 +128,7 @@ export function splitChangesUpdaterFactory( } /** Returns true if at least one split was updated */ - function update(flagsChange: [boolean | void, void | boolean[], void | boolean[], boolean | void] | [any, any, any]) { + function isThereUpdate(flagsChange: [boolean | void, void | boolean[], void | boolean[], boolean | void] | [any, any, any]) { const [, added, removed, ] = flagsChange; // There is at least one added or modified feature flag if (added && added.some((update: boolean) => update)) return true; @@ -174,11 +174,9 @@ export function splitChangesUpdaterFactory( splits.removeSplits(mutation.removed), segments.registerSegments(mutation.segments) ]).then((flagsChange) => { - const triggerSdkUpdate = update(flagsChange); - if (!triggerSdkUpdate) return true; if (splitsEventEmitter) { // To emit SDK_SPLITS_ARRIVED for server-side SDK, we must check that all registered segments have been fetched - return Promise.resolve(!splitsEventEmitter.splitsArrived || (since !== splitChanges.till && (isClientSide || checkAllSegmentsExist(segments)))) + return Promise.resolve(!splitsEventEmitter.splitsArrived || (since !== splitChanges.till && isThereUpdate(flagsChange) && (isClientSide || checkAllSegmentsExist(segments)))) .catch(() => false /** noop. just to handle a possible `checkAllSegmentsExist` rejection, before emitting SDK event */) .then(emitSplitsArrivedEvent => { // emit SDK events