Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-3858: Fix state update for registerContext #1121

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading