Skip to content

Commit 92a5c0f

Browse files
committed
refactor: smaller
1 parent 53d6c84 commit 92a5c0f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/pinia/src/store.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function createSetupStore<
249249
if (isListening) {
250250
debuggerEvents = event
251251
// avoid triggering this while the store is being built and the state is being set in pinia
252-
} else if (isListening === false && !store._hotUpdating) {
252+
} else if (!isListening && !store._hotUpdating) {
253253
// let patch send all the events together later
254254
/* istanbul ignore else */
255255
if (Array.isArray(debuggerEvents)) {
@@ -264,8 +264,8 @@ function createSetupStore<
264264
}
265265

266266
// internal state
267-
let isListening = false // set to true at the end
268-
let shouldTrigger = false // The initial value does not matter, and no need to set to true at the end
267+
let isListening: boolean | undefined // set to true at the end
268+
let shouldTrigger: boolean | undefined // The initial value does not matter, and no need to set to true at the end
269269
let subscriptions: Set<SubscriptionCallback<S>> = new Set()
270270
let actionSubscriptions: Set<StoreOnActionListener<Id, S, G, A>> = new Set()
271271
let debuggerEvents: DebuggerEvent[] | DebuggerEvent
@@ -460,12 +460,10 @@ function createSetupStore<
460460
assign({}, $subscribeOptions, options)
461461
)
462462

463-
const stop = () => {
463+
return () => {
464464
stop1()
465465
stop2()
466466
}
467-
468-
return stop
469467
})!
470468

471469
return removeSubscription

0 commit comments

Comments
 (0)