@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/dev/jsenv_navi.js
CHANGED
|
@@ -3209,6 +3209,12 @@ const actionWeakMap = new WeakMap();
|
|
|
3209
3209
|
*
|
|
3210
3210
|
* @param {Function} callback
|
|
3211
3211
|
* @param {object} [rootOptions]
|
|
3212
|
+
* @param {(params: any, action: object) => any} [rootOptions.provisionalValue] -
|
|
3213
|
+
* a value the action holds while a run is in flight and it has none of its
|
|
3214
|
+
* own, so a screen already knowing the answer draws it as a refresh rather
|
|
3215
|
+
* than a first load (data_states.md). Called at the start of every run whose
|
|
3216
|
+
* value is undefined; the answer replaces it as usual, and `undefined` means
|
|
3217
|
+
* "nothing known". A resource `GET` uses it to draw the row its store holds.
|
|
3212
3218
|
* @param {{ ms?: number, max?: number }} [rootOptions.keep] - how long an
|
|
3213
3219
|
* answer stays good once it has landed. Without it an answer lives exactly as
|
|
3214
3220
|
* long as something references it: the screen that asked goes away, and
|
|
@@ -3248,6 +3254,7 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
3248
3254
|
value,
|
|
3249
3255
|
resultToValue,
|
|
3250
3256
|
valueToData,
|
|
3257
|
+
provisionalValue,
|
|
3251
3258
|
dataDefault,
|
|
3252
3259
|
data = dataDefault,
|
|
3253
3260
|
|
|
@@ -3706,6 +3713,12 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
3706
3713
|
actionAbortMap.set(action, abort);
|
|
3707
3714
|
|
|
3708
3715
|
batch(() => {
|
|
3716
|
+
if (provisionalValue && valueSignal.peek() === undefined) {
|
|
3717
|
+
const provisional = provisionalValue(params, action);
|
|
3718
|
+
if (provisional !== undefined) {
|
|
3719
|
+
valueSignal.value = provisional;
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3709
3722
|
runningStateSignal.value = RUNNING;
|
|
3710
3723
|
if (!isPrerun) {
|
|
3711
3724
|
isPrerunSignal.value = false;
|
|
@@ -15129,17 +15142,15 @@ const resource = (
|
|
|
15129
15142
|
return item;
|
|
15130
15143
|
},
|
|
15131
15144
|
});
|
|
15132
|
-
const createRestActionForRoot = createRestActionFactoryForRoot(name, {
|
|
15133
|
-
idKey,
|
|
15134
|
-
store,
|
|
15135
|
-
declarationSite,
|
|
15136
|
-
});
|
|
15137
15145
|
// The row a GET designates, when the store already holds it — by its params:
|
|
15138
15146
|
// the value under idKey may be the id or any unique key (a route opening a
|
|
15139
15147
|
// user by id or by slug names both `id`), and a unique key may be given under
|
|
15140
|
-
// its own name
|
|
15141
|
-
//
|
|
15142
|
-
//
|
|
15148
|
+
// its own name. findItemByParams is what a GET draws while its request is in
|
|
15149
|
+
// flight (the action's provisionalValue). findItemInStore adds, when the
|
|
15150
|
+
// params name no row (a GET without params, or whose params carry no key),
|
|
15151
|
+
// the row the action last completed with: that fallback answers a GET under
|
|
15152
|
+
// a network policy (see applyNetworkPolicy) and only there — a GET of a row
|
|
15153
|
+
// the store lacks must draw its skeleton, never the row read just before.
|
|
15143
15154
|
const selectByAnyKey = (value) => {
|
|
15144
15155
|
const item = store.select(value);
|
|
15145
15156
|
if (item) {
|
|
@@ -15191,6 +15202,12 @@ const resource = (
|
|
|
15191
15202
|
return store.select(lastItemId) || null;
|
|
15192
15203
|
});
|
|
15193
15204
|
};
|
|
15205
|
+
const createRestActionForRoot = createRestActionFactoryForRoot(name, {
|
|
15206
|
+
idKey,
|
|
15207
|
+
store,
|
|
15208
|
+
findItemByParams,
|
|
15209
|
+
declarationSite,
|
|
15210
|
+
});
|
|
15194
15211
|
return createResource(name, {
|
|
15195
15212
|
idKey,
|
|
15196
15213
|
uniqueKeys,
|
|
@@ -16182,6 +16199,7 @@ const createRestActionFactoryForRoot = (
|
|
|
16182
16199
|
{
|
|
16183
16200
|
idKey,
|
|
16184
16201
|
store, // see array_signal_store.js
|
|
16202
|
+
findItemByParams,
|
|
16185
16203
|
declarationSite,
|
|
16186
16204
|
},
|
|
16187
16205
|
) => {
|
|
@@ -16253,6 +16271,16 @@ const createRestActionFactoryForRoot = (
|
|
|
16253
16271
|
return applyResultToValue(result);
|
|
16254
16272
|
},
|
|
16255
16273
|
valueToData: (itemId) => store.select(itemId),
|
|
16274
|
+
// While the request is out, the row the store already holds for these
|
|
16275
|
+
// params is drawn: the action starts on the "refresh over a known
|
|
16276
|
+
// answer" line of data_states.md rather than the first-load one.
|
|
16277
|
+
provisionalValue:
|
|
16278
|
+
verb === "GET"
|
|
16279
|
+
? (params) => {
|
|
16280
|
+
const item = untracked(() => findItemByParams(params));
|
|
16281
|
+
return item ? item[idKey] : undefined;
|
|
16282
|
+
}
|
|
16283
|
+
: undefined,
|
|
16256
16284
|
completeSideEffect: onActionComplete,
|
|
16257
16285
|
});
|
|
16258
16286
|
};
|