]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: innerPatch -> mergeReactiveObjects
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Oct 2021 14:43:05 +0000 (16:43 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Oct 2021 14:43:05 +0000 (16:43 +0200)
packages/pinia/src/store.ts

index 950b3bfd66ee36c1503dfecae5e309ab7ebd0651..0936d67ed785bc9007efb1546610b669200fdbfb 100644 (file)
@@ -49,7 +49,7 @@ import { IS_CLIENT } from './env'
 import { patchObject } from './hmr'
 import { addSubscription, triggerSubscriptions } from './subscriptions'
 
-function innerPatch<T extends StateTree>(
+function mergeReactiveObjects<T extends StateTree>(
   target: T,
   patchToApply: DeepPartial<T>
 ): T {
@@ -63,7 +63,7 @@ function innerPatch<T extends StateTree>(
       !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