From: Eduardo San Martin Morote Date: Mon, 25 Oct 2021 14:43:05 +0000 (+0200) Subject: refactor: innerPatch -> mergeReactiveObjects X-Git-Tag: @pinia/nuxt@0.1.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd13a8da060188ad43554bf189d033f10b00f938;p=thirdparty%2Fvuejs%2Fpinia.git refactor: innerPatch -> mergeReactiveObjects --- diff --git a/packages/pinia/src/store.ts b/packages/pinia/src/store.ts index 950b3bfd..0936d67e 100644 --- a/packages/pinia/src/store.ts +++ b/packages/pinia/src/store.ts @@ -49,7 +49,7 @@ import { IS_CLIENT } from './env' import { patchObject } from './hmr' import { addSubscription, triggerSubscriptions } from './subscriptions' -function innerPatch( +function mergeReactiveObjects( target: T, patchToApply: DeepPartial ): T { @@ -63,7 +63,7 @@ function innerPatch( !isRef(subPatch) && !isReactive(subPatch) ) { - target[key] = innerPatch(targetValue, subPatch) + target[key] = mergeReactiveObjects(targetValue, subPatch) } else { // @ts-expect-error: subPatch is a valid value target[key] = subPatch @@ -257,7 +257,7 @@ function createSetupStore< events: debuggerEvents as DebuggerEvent[], } } else { - innerPatch(pinia.state.value[$id], partialStateOrMutator) + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator) subscriptionMutation = { type: MutationType.patchObject, payload: partialStateOrMutator, @@ -460,7 +460,7 @@ function createSetupStore< prop.value = initialState[key] } else { // probably a reactive object, lets recursively assign - innerPatch(prop, initialState[key]) + mergeReactiveObjects(prop, initialState[key]) } } // transfer the ref to the pinia state to keep everything in sync