valdres 0.2.0-alpha.54 → 0.2.0-alpha.56
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 +7 -3
- package/dist/types/src/lib/setAtom.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -131,15 +131,18 @@ var isSelector = (state) => state && Object.hasOwn(state, "get");
|
|
|
131
131
|
var isSelectorFamily = (state) => state && Object.hasOwn(state, "__valdresSelectorFamilyMap");
|
|
132
132
|
|
|
133
133
|
// src/lib/setAtom.ts
|
|
134
|
+
var isFunction = (value) => {
|
|
135
|
+
return typeof value === "function";
|
|
136
|
+
};
|
|
134
137
|
var setAtom = (atom, newValue, data, skipOnSet = false) => {
|
|
135
138
|
const currentValue = getState(atom, data);
|
|
136
|
-
if (
|
|
139
|
+
if (isFunction(newValue)) {
|
|
137
140
|
newValue = newValue(currentValue);
|
|
138
141
|
if (isPromiseLike(newValue) || isPromiseLike(currentValue))
|
|
139
142
|
throw new Error("Todo, how should we handle this?");
|
|
140
143
|
}
|
|
141
144
|
if (atom.equal(currentValue, newValue))
|
|
142
|
-
return;
|
|
145
|
+
return newValue;
|
|
143
146
|
data.values.set(atom, newValue);
|
|
144
147
|
if (atom.onSet && !skipOnSet)
|
|
145
148
|
atom.onSet(newValue, data);
|
|
@@ -147,6 +150,7 @@ var setAtom = (atom, newValue, data, skipOnSet = false) => {
|
|
|
147
150
|
currentValue.__resolveEmptyAtomPromise__(newValue);
|
|
148
151
|
}
|
|
149
152
|
propagateUpdatedAtoms([atom], data);
|
|
153
|
+
return newValue;
|
|
150
154
|
};
|
|
151
155
|
|
|
152
156
|
// src/lib/initAtom.ts
|
|
@@ -770,7 +774,7 @@ var store = (id) => {
|
|
|
770
774
|
return storeFromStoreData(data);
|
|
771
775
|
};
|
|
772
776
|
// package.json
|
|
773
|
-
var version = "0.2.0-alpha.
|
|
777
|
+
var version = "0.2.0-alpha.55";
|
|
774
778
|
|
|
775
779
|
// src/globalStore.ts
|
|
776
780
|
if (globalThis.__valdres__) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Atom } from "../types/Atom";
|
|
2
2
|
import type { StoreData } from "../types/StoreData";
|
|
3
|
-
export declare const setAtom: <Value = any>(atom: Atom<Value>, newValue: Value, data: StoreData, skipOnSet?: boolean) =>
|
|
3
|
+
export declare const setAtom: <Value = any>(atom: Atom<Value>, newValue: Value | ((currentValue: Value) => Value), data: StoreData, skipOnSet?: boolean) => Value;
|
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.56",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eigil Sagafos"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "NODE_ENV=production bun build index.ts --outdir ./dist --packages external",
|
|
23
|
-
"build:types": "rm -rf dist/types && tsc",
|
|
23
|
+
"build:types": "rm -rf dist/types && bun run tsc",
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"access": "public",
|
|
37
37
|
"registry": "https://registry.npmjs.org/"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "b3f91557fd99701880610a9ef2d317fe84135f64"
|
|
40
40
|
}
|