Skip to content

Commit

Permalink
(fix) O3-3858 : Fix state update for registerContext (#1121)
Browse files Browse the repository at this point in the history
  • Loading branch information
kb019 authored Aug 23, 2024
1 parent c45a0e3 commit 237bda7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/framework/esm-context/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export function registerContext<T extends {} = {}>(namespace: string, initialVal
);
}

state[namespace] = initialValue === nothing ? {} : initialValue;
return state;
return Object.assign({}, state, { namespace: initialValue === nothing ? {} : initialValue });
});
}

Expand Down Expand Up @@ -83,7 +82,7 @@ export function updateContext<T extends {} = {}>(namespace: string, update: (sta
}

state[namespace] = update(state[namespace] as T);
return state;
return Object.assign({}, state);
});
}

Expand Down
10 changes: 5 additions & 5 deletions packages/framework/esm-framework/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ ___

#### Defined in

[packages/framework/esm-context/src/context.ts:90](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L90)
[packages/framework/esm-context/src/context.ts:89](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L89)

___

Expand Down Expand Up @@ -3366,7 +3366,7 @@ Returns an _immutable_ version of the state of the namespace as it is currently

#### Defined in

[packages/framework/esm-context/src/context.ts:55](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L55)
[packages/framework/esm-context/src/context.ts:54](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L54)

___

Expand Down Expand Up @@ -3433,7 +3433,7 @@ A function to unsubscribe from the context

#### Defined in

[packages/framework/esm-context/src/context.ts:99](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L99)
[packages/framework/esm-context/src/context.ts:98](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L98)

___

Expand All @@ -3456,7 +3456,7 @@ will remove the namespace and all associated data.

#### Defined in

[packages/framework/esm-context/src/context.ts:46](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L46)
[packages/framework/esm-context/src/context.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L45)

___

Expand Down Expand Up @@ -3485,7 +3485,7 @@ Updates a namespace in the global context. If the namespace does not exist, it i

#### Defined in

[packages/framework/esm-context/src/context.ts:79](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L79)
[packages/framework/esm-context/src/context.ts:78](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-context/src/context.ts#L78)

___

Expand Down

0 comments on commit 237bda7

Please sign in to comment.