resourcerer 2.0.3 → 2.0.5
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/build/lib/resourcerer.js +1 -0
- package/build/lib/utils.js +2 -1
- package/package.json +1 -1
- package/test/utils.test.js +8 -2
package/build/lib/resourcerer.js
CHANGED
|
@@ -327,6 +327,7 @@ function partitionResources(resourcesToUpdate, loadingStates) {
|
|
|
327
327
|
return resourcesToUpdate.reduce((memo, [name, config]) => (config.refetch ||
|
|
328
328
|
config.force ||
|
|
329
329
|
config.prefetch ||
|
|
330
|
+
config.lazy ||
|
|
330
331
|
!hasLoaded(loadingStates[getResourceState(name)]) ||
|
|
331
332
|
getModelFromCache(config)?.lazy) ?
|
|
332
333
|
[memo[0], memo[1].concat([[name, config]])]
|
package/build/lib/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const hasErrored = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "error");
|
|
2
|
-
export const isLoading = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "loading")
|
|
2
|
+
export const isLoading = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "loading") &&
|
|
3
|
+
!qualifyLoadingStates(loadingStates).some((state) => state === "error");
|
|
3
4
|
export const hasLoaded = (loadingStates) => qualifyLoadingStates(loadingStates).every((state) => state === "loaded");
|
|
4
5
|
export const isPending = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "pending");
|
|
5
6
|
export function noOp() { }
|
package/package.json
CHANGED
package/test/utils.test.js
CHANGED
|
@@ -39,9 +39,10 @@ describe("Utils", () => {
|
|
|
39
39
|
|
|
40
40
|
describe("isLoading method", () => {
|
|
41
41
|
it("returns true if any loading state is loading", () => {
|
|
42
|
-
expect(isLoading(["
|
|
42
|
+
expect(isLoading(["pending", "loading", "loading"])).toBe(true);
|
|
43
|
+
expect(isLoading(["loaded", "loading"])).toBe(true);
|
|
43
44
|
expect(isLoading("loading")).toBe(true);
|
|
44
|
-
expect(Utils.isLoading(["
|
|
45
|
+
expect(Utils.isLoading(["loaded", "loading"])).toBe(true);
|
|
45
46
|
expect(Utils.isLoading("loading")).toBe(true);
|
|
46
47
|
});
|
|
47
48
|
|
|
@@ -52,6 +53,11 @@ describe("Utils", () => {
|
|
|
52
53
|
expect(Utils.isLoading("loaded")).toBe(false);
|
|
53
54
|
});
|
|
54
55
|
|
|
56
|
+
it("returns false if any other loading states have errored", () => {
|
|
57
|
+
expect(isLoading(["error", "loading", "loaded"])).toBe(false);
|
|
58
|
+
expect(Utils.isLoading(["error", "loading", "loaded"])).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
55
61
|
it("returns false if an undefined loading state is passed", () => {
|
|
56
62
|
expect(isLoading(undefined)).toBe(false);
|
|
57
63
|
expect(Utils.isLoading(undefined)).toBe(false);
|