Skip to content

Commit 648d184

Browse files
committed
[transactions] startTransaction can mutate safely
1 parent bf6f274 commit 648d184

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/store.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import {
104104
collForEach,
105105
collHas,
106106
collIsEmpty,
107+
collSize2,
107108
collSize3,
108109
collSize4,
109110
} from './common/coll';
@@ -1198,12 +1199,12 @@ export const createStore: typeof createStoreDecl = (): Store => {
11981199
};
11991200

12001201
const startTransaction = (): Store => {
1201-
if (transactions == 0) {
1202-
callListeners(startTransactionListeners, undefined, false, false);
1203-
}
12041202
if (transactions != -1) {
12051203
transactions++;
12061204
}
1205+
if (transactions == 1) {
1206+
callListeners(startTransactionListeners, undefined, false, false);
1207+
}
12071208
return store;
12081209
};
12091210

@@ -1413,7 +1414,9 @@ export const createStore: typeof createStoreDecl = (): Store => {
14131414
valueIds: pairCollSize2(valueIdsListeners),
14141415
value: pairCollSize2(valueListeners),
14151416
invalidValue: pairCollSize2(invalidValueListeners),
1416-
transaction: pairCollSize2(finishTransactionListeners),
1417+
transaction:
1418+
collSize2(startTransactionListeners) +
1419+
pairCollSize2(finishTransactionListeners),
14171420
}
14181421
: {};
14191422

0 commit comments

Comments
 (0)