Skip to content

Commit

Permalink
fix: only skip all initial render when network-only and add missing s…
Browse files Browse the repository at this point in the history
…tale flag in subscription (#23)

* fix: only skip all initial render when network-only

* fix: same fix for network-only
  • Loading branch information
bill-min authored Jun 7, 2024
1 parent 0035cdc commit 8b2b9b5
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class {
this.shouldQuery = false;
if (!--skipQueries) {
this.removeListener("render", onRender);
this.doQuery({ requestPolicy: "cache-first" });
}
};
this.on("render", onRender);
Expand Down Expand Up @@ -86,16 +87,20 @@ class {
}
this.unsubscribe = pipe(
getClient(undefined, this.input.name).query(this.input.query, this.input.variables, {
requestPolicy: this.input.requestPolicy,
...options,
}),
subscribe(({ data, error }) => {
getClient(undefined, this.input.name).query(
this.input.query,
this.input.variables,
{
requestPolicy: this.input.requestPolicy,
...options,
},
),
subscribe(({ data, error, stale }) => {
this.stopTimeout();
this.state.data = data;
this.state.error = error;
this.state.fetching = false;
})
this.state.fetching = !!stale;
}),
).unsubscribe;
}
}
Expand All @@ -105,7 +110,7 @@ class {
state,
(options) => {
component.doQuery({ requestPolicy: "network-only", ...options });
}
},
)/>
</if>
<else>
Expand Down

0 comments on commit 8b2b9b5

Please sign in to comment.