@spoosh/plugin-initial-data 0.2.4 → 0.2.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/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function initialDataPlugin() {
|
|
|
41
41
|
}
|
|
42
42
|
return response2;
|
|
43
43
|
}
|
|
44
|
-
if (!context.
|
|
44
|
+
if (!context.instanceId) {
|
|
45
45
|
const response2 = await next();
|
|
46
46
|
if (!response2.error) {
|
|
47
47
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -50,7 +50,7 @@ function initialDataPlugin() {
|
|
|
50
50
|
}
|
|
51
51
|
return response2;
|
|
52
52
|
}
|
|
53
|
-
if (initialDataAppliedFor.has(context.
|
|
53
|
+
if (initialDataAppliedFor.has(context.instanceId)) {
|
|
54
54
|
const response2 = await next();
|
|
55
55
|
if (!response2.error) {
|
|
56
56
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -61,7 +61,7 @@ function initialDataPlugin() {
|
|
|
61
61
|
}
|
|
62
62
|
const cached = context.stateManager.getCache(context.queryKey);
|
|
63
63
|
if (cached?.state?.data !== void 0) {
|
|
64
|
-
initialDataAppliedFor.add(context.
|
|
64
|
+
initialDataAppliedFor.add(context.instanceId);
|
|
65
65
|
const response2 = await next();
|
|
66
66
|
if (!response2.error) {
|
|
67
67
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -70,7 +70,7 @@ function initialDataPlugin() {
|
|
|
70
70
|
}
|
|
71
71
|
return response2;
|
|
72
72
|
}
|
|
73
|
-
initialDataAppliedFor.add(context.
|
|
73
|
+
initialDataAppliedFor.add(context.instanceId);
|
|
74
74
|
context.stateManager.setCache(context.queryKey, {
|
|
75
75
|
state: {
|
|
76
76
|
data: pluginOptions.initialData,
|
|
@@ -95,8 +95,8 @@ function initialDataPlugin() {
|
|
|
95
95
|
},
|
|
96
96
|
lifecycle: {
|
|
97
97
|
onUnmount(context) {
|
|
98
|
-
if (context.
|
|
99
|
-
initialDataAppliedFor.delete(context.
|
|
98
|
+
if (context.instanceId) {
|
|
99
|
+
initialDataAppliedFor.delete(context.instanceId);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ function initialDataPlugin() {
|
|
|
15
15
|
}
|
|
16
16
|
return response2;
|
|
17
17
|
}
|
|
18
|
-
if (!context.
|
|
18
|
+
if (!context.instanceId) {
|
|
19
19
|
const response2 = await next();
|
|
20
20
|
if (!response2.error) {
|
|
21
21
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -24,7 +24,7 @@ function initialDataPlugin() {
|
|
|
24
24
|
}
|
|
25
25
|
return response2;
|
|
26
26
|
}
|
|
27
|
-
if (initialDataAppliedFor.has(context.
|
|
27
|
+
if (initialDataAppliedFor.has(context.instanceId)) {
|
|
28
28
|
const response2 = await next();
|
|
29
29
|
if (!response2.error) {
|
|
30
30
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -35,7 +35,7 @@ function initialDataPlugin() {
|
|
|
35
35
|
}
|
|
36
36
|
const cached = context.stateManager.getCache(context.queryKey);
|
|
37
37
|
if (cached?.state?.data !== void 0) {
|
|
38
|
-
initialDataAppliedFor.add(context.
|
|
38
|
+
initialDataAppliedFor.add(context.instanceId);
|
|
39
39
|
const response2 = await next();
|
|
40
40
|
if (!response2.error) {
|
|
41
41
|
context.stateManager.setMeta(context.queryKey, {
|
|
@@ -44,7 +44,7 @@ function initialDataPlugin() {
|
|
|
44
44
|
}
|
|
45
45
|
return response2;
|
|
46
46
|
}
|
|
47
|
-
initialDataAppliedFor.add(context.
|
|
47
|
+
initialDataAppliedFor.add(context.instanceId);
|
|
48
48
|
context.stateManager.setCache(context.queryKey, {
|
|
49
49
|
state: {
|
|
50
50
|
data: pluginOptions.initialData,
|
|
@@ -69,8 +69,8 @@ function initialDataPlugin() {
|
|
|
69
69
|
},
|
|
70
70
|
lifecycle: {
|
|
71
71
|
onUnmount(context) {
|
|
72
|
-
if (context.
|
|
73
|
-
initialDataAppliedFor.delete(context.
|
|
72
|
+
if (context.instanceId) {
|
|
73
|
+
initialDataAppliedFor.delete(context.instanceId);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-initial-data",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Initial data plugin for Spoosh - show data immediately before fetch completes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.12.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
40
|
-
"@spoosh/test-utils": "0.1.
|
|
39
|
+
"@spoosh/core": "0.12.0",
|
|
40
|
+
"@spoosh/test-utils": "0.1.8"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|