Skip to content

Commit

Permalink
approach improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Zamora committed Nov 2, 2023
1 parent 2e7446b commit 065c6e0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 2 additions & 4 deletions src/sync/polling/updaters/splitChangesUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 065c6e0

Please sign in to comment.