valdres 0.2.0-alpha.45 → 0.2.0-alpha.46
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
|
@@ -628,24 +628,30 @@ var transaction = (callback, data, autoCommit = true) => {
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
|
-
const result = callback(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
631
|
+
const result = callback({
|
|
632
|
+
set: txnSet,
|
|
633
|
+
get: txnGet,
|
|
634
|
+
reset: txnReset,
|
|
635
|
+
commit,
|
|
636
|
+
scope: (scopeId, callback2) => {
|
|
637
|
+
if (scopeId in data.scopes) {
|
|
638
|
+
const scopedData = data.scopes[scopeId];
|
|
639
|
+
if (scopedTransactions?.[scopeId] === undefined) {
|
|
640
|
+
scopedTransactions ||= {};
|
|
641
|
+
transaction(({ set, get, reset, commit: commit2, scope }) => {
|
|
642
|
+
scopedTransactions[scopeId] = [
|
|
643
|
+
set,
|
|
644
|
+
get,
|
|
645
|
+
reset,
|
|
646
|
+
commit2,
|
|
647
|
+
scope
|
|
648
|
+
];
|
|
649
|
+
}, scopedData, false);
|
|
650
|
+
}
|
|
651
|
+
callback2(...scopedTransactions[scopeId]);
|
|
652
|
+
} else {
|
|
653
|
+
throw new Error("Scope not found");
|
|
645
654
|
}
|
|
646
|
-
callback2(...scopedTransactions[scopeId]);
|
|
647
|
-
} else {
|
|
648
|
-
throw new Error("Scope not found");
|
|
649
655
|
}
|
|
650
656
|
});
|
|
651
657
|
if (autoCommit)
|
|
@@ -721,7 +727,7 @@ var store = (id) => {
|
|
|
721
727
|
return storeFromStoreData(data);
|
|
722
728
|
};
|
|
723
729
|
// package.json
|
|
724
|
-
var version = "0.2.0-alpha.
|
|
730
|
+
var version = "0.2.0-alpha.45";
|
|
725
731
|
|
|
726
732
|
// src/globalStore.ts
|
|
727
733
|
if (globalThis.__valdres__) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,3 +27,5 @@ export type { SetAtomValue } from "./src/types/SetAtomValue";
|
|
|
27
27
|
export type { State } from "./src/types/State";
|
|
28
28
|
export type { Store } from "./src/types/Store";
|
|
29
29
|
export type { StoreData } from "./src/types/StoreData";
|
|
30
|
+
export type { TransactionFn } from "./src/types/TransactionFn";
|
|
31
|
+
export type { TransactionInterface } from "./src/types/TransactionInterface";
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type { SetAtom } from "./SetAtom";
|
|
4
|
-
export type TransactionFn = (set: SetAtom, get: GetValue, reset: ResetAtom, commit: () => void, scope: (scopeId: string, callback: TransactionFn) => void) => void;
|
|
1
|
+
import type { TransactionInterface } from "./TransactionInterface";
|
|
2
|
+
export type TransactionFn = (args: TransactionInterface) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GetValue } from "./GetValue";
|
|
2
|
+
import type { ResetAtom } from "./ResetAtom";
|
|
3
|
+
import type { SetAtom } from "./SetAtom";
|
|
4
|
+
import type { TransactionFn } from "./TransactionFn";
|
|
5
|
+
export type TransactionInterface = {
|
|
6
|
+
set: SetAtom;
|
|
7
|
+
get: GetValue;
|
|
8
|
+
reset: ResetAtom;
|
|
9
|
+
commit: () => void;
|
|
10
|
+
scope: (scopeId: string, callback: TransactionFn) => void;
|
|
11
|
+
};
|
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.46",
|
|
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": "ffb8cb2b276f5f8ff00a7f922776218a6697ea26"
|
|
40
40
|
}
|