dreamstate
Version:
Store management library based on react context and observers
26 lines (24 loc) • 965 B
JavaScript
/**
* A utility class for extending context manager state with structured state management and shallow comparison.
*
* This class is used by the `ContextManager` to efficiently track and compare nested state updates.
* It helps in optimizing reactivity by ensuring that updates trigger only when relevant changes occur.
*/
var NestedStore = /** @class */function () {
function NestedStore() {}
/**
* Merges the provided partial state with the existing state and returns a shallow copy.
*
* @template T - The type of the state.
* @param {Partial<T>} state The next state partial to merge with the existing state and commit update.
* @returns {TNested<T>} A merged shallow copy based on the partial state parameter.
*/
NestedStore.prototype.asMerged = function (state) {
if (state === void 0) {
state = {};
}
return Object.assign(new NestedStore(), this, state);
};
return NestedStore;
}();
export { NestedStore };