valdres 0.2.0-alpha.46 → 0.2.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -566,6 +566,13 @@ var recursivlyResetTxnSelectorCache = (state, txnSubscribers, txnSelectorCache)
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
|
+
var captureScopedTransaction = (scopedData) => {
|
|
570
|
+
let txn;
|
|
571
|
+
transaction((scopedTxn) => {
|
|
572
|
+
txn = scopedTxn;
|
|
573
|
+
}, scopedData, false);
|
|
574
|
+
return txn;
|
|
575
|
+
};
|
|
569
576
|
var transaction = (callback, data, autoCommit = true) => {
|
|
570
577
|
let txnAtomMap = new Map;
|
|
571
578
|
let txnSelectorCache = new Map;
|
|
@@ -624,7 +631,7 @@ var transaction = (callback, data, autoCommit = true) => {
|
|
|
624
631
|
dirtySelectors.clear();
|
|
625
632
|
if (scopedTransactions) {
|
|
626
633
|
for (const scopedTxn of Object.values(scopedTransactions)) {
|
|
627
|
-
scopedTxn
|
|
634
|
+
scopedTxn.commit();
|
|
628
635
|
}
|
|
629
636
|
}
|
|
630
637
|
};
|
|
@@ -636,21 +643,15 @@ var transaction = (callback, data, autoCommit = true) => {
|
|
|
636
643
|
scope: (scopeId, callback2) => {
|
|
637
644
|
if (scopeId in data.scopes) {
|
|
638
645
|
const scopedData = data.scopes[scopeId];
|
|
639
|
-
if (scopedTransactions
|
|
640
|
-
scopedTransactions
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
get,
|
|
645
|
-
reset,
|
|
646
|
-
commit2,
|
|
647
|
-
scope
|
|
648
|
-
];
|
|
649
|
-
}, scopedData, false);
|
|
646
|
+
if (scopedTransactions === undefined) {
|
|
647
|
+
scopedTransactions = {};
|
|
648
|
+
}
|
|
649
|
+
if (scopedTransactions[scopeId] === undefined) {
|
|
650
|
+
scopedTransactions[scopeId] = captureScopedTransaction(scopedData);
|
|
650
651
|
}
|
|
651
|
-
callback2(
|
|
652
|
+
return callback2(scopedTransactions[scopeId]);
|
|
652
653
|
} else {
|
|
653
|
-
throw new Error(
|
|
654
|
+
throw new Error(`Scope '${scopeId}' not found. Registered scopes: ${Object.keys(data.scopes).join(", ")}`);
|
|
654
655
|
}
|
|
655
656
|
}
|
|
656
657
|
});
|
|
@@ -727,7 +728,7 @@ var store = (id) => {
|
|
|
727
728
|
return storeFromStoreData(data);
|
|
728
729
|
};
|
|
729
730
|
// package.json
|
|
730
|
-
var version = "0.2.0-alpha.
|
|
731
|
+
var version = "0.2.0-alpha.47";
|
|
731
732
|
|
|
732
733
|
// src/globalStore.ts
|
|
733
734
|
if (globalThis.__valdres__) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StoreData } from "../types/StoreData";
|
|
2
2
|
import type { TransactionFn } from "../types/TransactionFn";
|
|
3
|
-
export declare const transaction: (callback: TransactionFn, data: StoreData, autoCommit?: boolean) =>
|
|
3
|
+
export declare const transaction: (callback: TransactionFn, data: StoreData, autoCommit?: boolean) => any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TransactionInterface } from "./TransactionInterface";
|
|
2
|
-
export type TransactionFn = (args: TransactionInterface) =>
|
|
2
|
+
export type TransactionFn = (args: TransactionInterface) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valdres",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.48",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eigil Sagafos"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"access": "public",
|
|
37
37
|
"registry": "https://registry.npmjs.org/"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "65baebd620f63795b27466864bf54a249323bd57"
|
|
40
40
|
}
|