Skip to content

Commit

Permalink
use skipToken with subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Jul 16, 2024
1 parent be2f663 commit 1166c2f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/query-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export function createQueryHooksHelpers<P extends rspc.Procedures>() {
function handleSubscription(
client: rspc.Client<P>,
path: string[],
input: unknown,
input: unknown | tanstack.SkipToken,
opts?: () => SubscriptionOptions<unknown, unknown> | undefined,
): undefined | (() => void) {
if (!(opts?.()?.enabled ?? true)) return;
if (!(opts?.()?.enabled ?? true) || input === tanstack.skipToken) return;

let isStopped = false;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function createHooks<P extends rspc.Procedures>() {
function useSubscription(
path: string[],
...[input, opts]: [
unknown,
unknown | tanstack.SkipToken,
queryCore.SubscriptionOptions<unknown, unknown> | undefined,
]
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export type ProcedureProxyMethods<
: P["variant"] extends "subscription"
? {
useSubscription(
input: P["input"],
input: P["input"] | tanstack.SkipToken,
opts?: Partial<
rspc.SubscriptionObserver<rspc.ProcedureResult<P>, unknown>
>,
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-query/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function createHooks<P extends rspc.Procedures>() {
function createSubscription(
path: string[],
...[input, opts]: [
solid.Accessor<unknown>,
solid.Accessor<unknown | tanstack.SkipToken>,
opts:
| solid.Accessor<queryCore.SubscriptionOptions<unknown, unknown>>
| undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export type ProcedureProxyMethods<
: P["variant"] extends "subscription"
? {
createSubscription(
input: solid.Accessor<P["input"]>,
input: solid.Accessor<P["input"] | tanstack.SkipToken>,
opts?: solid.Accessor<
Partial<
rspc.SubscriptionObserver<rspc.ProcedureResult<P>, unknown>
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function createHooks<P extends rspc.Procedures>() {
function createSubscription(
path: string[],
...[input, opts]: [
tanstack.StoreOrVal<unknown>,
tanstack.StoreOrVal<unknown | tanstack.SkipToken>,
opts:
| tanstack.StoreOrVal<queryCore.SubscriptionOptions<unknown, unknown>>
| undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export type ProcedureProxyMethods<
: P["variant"] extends "subscription"
? {
createSubscription(
input: tanstack.StoreOrVal<P["input"]>,
input: tanstack.StoreOrVal<P["input"] | tanstack.SkipToken>,
opts?: tanstack.StoreOrVal<
Partial<
rspc.SubscriptionObserver<rspc.ProcedureResult<P>, unknown>
Expand Down

0 comments on commit 1166c2f

Please sign in to comment.