valdres 0.2.0-pre.14 → 0.2.0-pre.15

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
@@ -918,6 +918,12 @@ class Transaction {
918
918
  throw new Error(`Scope '${scopeId}' not found. Registered scopes: ${Object.keys(this.data.scopes).join(", ")}`);
919
919
  }
920
920
  };
921
+ parentScope = (callback) => {
922
+ if (!this._parentTransaction) {
923
+ this._parentTransaction = new Transaction(this.data.parent);
924
+ }
925
+ return this._parentTransaction.execute(callback, false);
926
+ };
921
927
  reset = (atom) => {
922
928
  const value = getAtomInitValue(atom, this.data, this.initializedAtomsSet);
923
929
  this.atomMap.set(atom, value);
@@ -940,6 +946,9 @@ class Transaction {
940
946
  scopedTxn.commit();
941
947
  }
942
948
  }
949
+ if (this._parentTransaction) {
950
+ this._parentTransaction.commit();
951
+ }
943
952
  };
944
953
  get atomMap() {
945
954
  if (!this._atomMap)
@@ -1385,9 +1394,9 @@ var isFamilySelector = (state) => isFamilyState(state) && isSelector(state);
1385
1394
 
1386
1395
  // src/index.ts
1387
1396
  if (globalThis.__valdres__) {
1388
- throw new Error(`Error! An instance of valdres is already loaded. Loaded: ${globalThis.__valdres__}. Attempted to load: ${"0.2.0-pre.14"}`);
1397
+ throw new Error(`Error! An instance of valdres is already loaded. Loaded: ${globalThis.__valdres__}. Attempted to load: ${"0.2.0-pre.15"}`);
1389
1398
  } else {
1390
- globalThis.__valdres__ = "0.2.0-pre.14";
1399
+ globalThis.__valdres__ = "0.2.0-pre.15";
1391
1400
  }
1392
1401
  export {
1393
1402
  store,
@@ -19,6 +19,7 @@ export declare class Transaction {
19
19
  set: <V>(atom: Atom<V>, value: V | ((currentValue: V) => V)) => V;
20
20
  del: (atom: AtomFamilyAtom<any, any>) => void;
21
21
  scope: (scopeId: string, callback: (txn: Transaction) => any) => any;
22
+ parentScope: (callback: (txn: Transaction) => any) => any;
22
23
  reset: (atom: Atom) => any;
23
24
  execute: (callback: TransactionFn, autoCommit?: boolean) => any;
24
25
  commit: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valdres",
3
- "version": "0.2.0-pre.14",
3
+ "version": "0.2.0-pre.15",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Eigil Sagafos"