Skip to content

Commit

Permalink
Make status property optional, to avoid an interface breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Sep 10, 2024
1 parent 94fd37a commit a3fc06f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1.14.0 (September XX, 2024)
- Added `status` property to Split reducer's slice of state to track the readiness state of non-default clients (Related to https://github.com/splitio/redux-client/issues/113).
- Added `lastUpdate` and `isTimedout` properties to the object returned by the `getStatus` helper and `selectTreatmentAndStatus` and `selectTreatmentWithConfigAndStatus` selectors, to expose the last event timestamp and the timedout status of the SDK clients (Related to https://github.com/splitio/redux-client/issues/113).
- Updated @splitsoftware/splitio package to version 10.28.0 that includes minor updates:
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
Expand Down
9 changes: 4 additions & 5 deletions src/__tests__/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const initialState: ISplitState = {
isDestroyed: false,
lastUpdate: 0,
treatments: {},
status: {}
};

const key = 'userkey';
Expand Down Expand Up @@ -128,7 +127,7 @@ describe('Split reducer', () => {
[key]: treatments.test_split,
},
},
status: action.type === 'ADD_TREATMENTS' ? {} : {
status: action.type === 'ADD_TREATMENTS' ? undefined : {
[key]: {
...initialStatus,
isReady,
Expand Down Expand Up @@ -164,7 +163,7 @@ describe('Split reducer', () => {
[key]: newTreatments.test_split,
},
},
status: action.type === 'ADD_TREATMENTS' ? {} : {
status: action.type === 'ADD_TREATMENTS' ? undefined : {
[key]: {
...initialStatus,
isReady,
Expand Down Expand Up @@ -199,7 +198,7 @@ describe('Split reducer', () => {
[key]: newTreatments.test_split,
},
},
status: action.type === 'ADD_TREATMENTS' ? {} : {
status: action.type === 'ADD_TREATMENTS' ? undefined : {
[key]: {
...initialStatus,
isReady,
Expand Down Expand Up @@ -235,7 +234,7 @@ describe('Split reducer', () => {
[key]: newTreatments.test_split,
},
},
status: action.type === 'ADD_TREATMENTS' ? {} : {
status: action.type === 'ADD_TREATMENTS' ? undefined : {
[key]: {
...initialStatus,
isReady,
Expand Down
3 changes: 1 addition & 2 deletions src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ export const initialStatus = {
const initialState: ISplitState = {
...initialStatus,
treatments: {},
status: {},
};

function setStatus(state: ISplitState, patch: Partial<IStatus>, key?: string) {
return key ? {
...state,
status: {
...state.status,
[key]: state.status[key] ? {
[key]: state.status && state.status[key] ? {
...state.status[key],
...patch,
} : {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface ISplitState extends IStatus {
/**
* `status` is a nested object property that contains the readiness status of the non-default clients.
*/
status: {
status?: {
[key: string]: IStatus;
};
}
Expand Down

0 comments on commit a3fc06f

Please sign in to comment.