@jsenv/navi 0.29.227 → 0.29.228
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/dev/jsenv_navi.js +36 -8
- package/dist/dev/jsenv_navi.js.map +3 -3
- package/dist/jsenv_navi.js +36 -8
- package/dist/jsenv_navi.js.map +3 -3
- package/docs/data_states.md +7 -0
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -3149,6 +3149,12 @@ const actionWeakMap = new WeakMap();
|
|
|
3149
3149
|
*
|
|
3150
3150
|
* @param {Function} callback
|
|
3151
3151
|
* @param {object} [rootOptions]
|
|
3152
|
+
* @param {(params: any, action: object) => any} [rootOptions.provisionalValue] -
|
|
3153
|
+
* a value the action holds while a run is in flight and it has none of its
|
|
3154
|
+
* own, so a screen already knowing the answer draws it as a refresh rather
|
|
3155
|
+
* than a first load (data_states.md). Called at the start of every run whose
|
|
3156
|
+
* value is undefined; the answer replaces it as usual, and `undefined` means
|
|
3157
|
+
* "nothing known". A resource `GET` uses it to draw the row its store holds.
|
|
3152
3158
|
* @param {{ ms?: number, max?: number }} [rootOptions.keep] - how long an
|
|
3153
3159
|
* answer stays good once it has landed. Without it an answer lives exactly as
|
|
3154
3160
|
* long as something references it: the screen that asked goes away, and
|
|
@@ -3188,6 +3194,7 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
3188
3194
|
value,
|
|
3189
3195
|
resultToValue,
|
|
3190
3196
|
valueToData,
|
|
3197
|
+
provisionalValue,
|
|
3191
3198
|
dataDefault,
|
|
3192
3199
|
data = dataDefault,
|
|
3193
3200
|
|
|
@@ -3646,6 +3653,12 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
3646
3653
|
actionAbortMap.set(action, abort);
|
|
3647
3654
|
|
|
3648
3655
|
batch(() => {
|
|
3656
|
+
if (provisionalValue && valueSignal.peek() === undefined) {
|
|
3657
|
+
const provisional = provisionalValue(params, action);
|
|
3658
|
+
if (provisional !== undefined) {
|
|
3659
|
+
valueSignal.value = provisional;
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3649
3662
|
runningStateSignal.value = RUNNING;
|
|
3650
3663
|
if (!isPrerun) {
|
|
3651
3664
|
isPrerunSignal.value = false;
|
|
@@ -14859,17 +14872,15 @@ const resource = (
|
|
|
14859
14872
|
return item;
|
|
14860
14873
|
},
|
|
14861
14874
|
});
|
|
14862
|
-
const createRestActionForRoot = createRestActionFactoryForRoot(name, {
|
|
14863
|
-
idKey,
|
|
14864
|
-
store,
|
|
14865
|
-
declarationSite,
|
|
14866
|
-
});
|
|
14867
14875
|
// The row a GET designates, when the store already holds it — by its params:
|
|
14868
14876
|
// the value under idKey may be the id or any unique key (a route opening a
|
|
14869
14877
|
// user by id or by slug names both `id`), and a unique key may be given under
|
|
14870
|
-
// its own name
|
|
14871
|
-
//
|
|
14872
|
-
//
|
|
14878
|
+
// its own name. findItemByParams is what a GET draws while its request is in
|
|
14879
|
+
// flight (the action's provisionalValue). findItemInStore adds, when the
|
|
14880
|
+
// params name no row (a GET without params, or whose params carry no key),
|
|
14881
|
+
// the row the action last completed with: that fallback answers a GET under
|
|
14882
|
+
// a network policy (see applyNetworkPolicy) and only there — a GET of a row
|
|
14883
|
+
// the store lacks must draw its skeleton, never the row read just before.
|
|
14873
14884
|
const selectByAnyKey = (value) => {
|
|
14874
14885
|
const item = store.select(value);
|
|
14875
14886
|
if (item) {
|
|
@@ -14921,6 +14932,12 @@ const resource = (
|
|
|
14921
14932
|
return store.select(lastItemId) || null;
|
|
14922
14933
|
});
|
|
14923
14934
|
};
|
|
14935
|
+
const createRestActionForRoot = createRestActionFactoryForRoot(name, {
|
|
14936
|
+
idKey,
|
|
14937
|
+
store,
|
|
14938
|
+
findItemByParams,
|
|
14939
|
+
declarationSite,
|
|
14940
|
+
});
|
|
14924
14941
|
return createResource(name, {
|
|
14925
14942
|
idKey,
|
|
14926
14943
|
uniqueKeys,
|
|
@@ -15912,6 +15929,7 @@ const createRestActionFactoryForRoot = (
|
|
|
15912
15929
|
{
|
|
15913
15930
|
idKey,
|
|
15914
15931
|
store, // see array_signal_store.js
|
|
15932
|
+
findItemByParams,
|
|
15915
15933
|
declarationSite,
|
|
15916
15934
|
},
|
|
15917
15935
|
) => {
|
|
@@ -15983,6 +16001,16 @@ const createRestActionFactoryForRoot = (
|
|
|
15983
16001
|
return applyResultToValue(result);
|
|
15984
16002
|
},
|
|
15985
16003
|
valueToData: (itemId) => store.select(itemId),
|
|
16004
|
+
// While the request is out, the row the store already holds for these
|
|
16005
|
+
// params is drawn: the action starts on the "refresh over a known
|
|
16006
|
+
// answer" line of data_states.md rather than the first-load one.
|
|
16007
|
+
provisionalValue:
|
|
16008
|
+
verb === "GET"
|
|
16009
|
+
? (params) => {
|
|
16010
|
+
const item = untracked(() => findItemByParams(params));
|
|
16011
|
+
return item ? item[idKey] : undefined;
|
|
16012
|
+
}
|
|
16013
|
+
: undefined,
|
|
15986
16014
|
completeSideEffect: onActionComplete,
|
|
15987
16015
|
});
|
|
15988
16016
|
};
|