generated from Hebilicious/nuxt-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bea7d7
commit 8e72f91
Showing
4 changed files
with
44 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
packages/vue-query-nuxt/src/runtime/composables/defineVueQueryPluginCallback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import type { PluginCallbackParameters, ReturnedByPlugin } from "#build/internal.vue-query-plugin-callback" | ||
import type { PluginCallbackParameters, ReturnedByPlugin } from "../types" | ||
|
||
export const defineVueQueryPluginCallback = (callback: (pluginCallbackParameters: PluginCallbackParameters) => ReturnedByPlugin): typeof callback => callback | ||
export function defineVueQueryPluginCallback<T extends ReturnedByPlugin>( | ||
callback: (callbackParameters: PluginCallbackParameters) => T | ||
): (callbackParameters: PluginCallbackParameters) => T { | ||
return callback | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
import { type QueryClient } from "@tanstack/vue-query" | ||
import type { PluginCallbackParameters, ReturnedByPlugin } from "./types" | ||
|
||
export type ReturnedByPlugin = | ||
| void | ||
| Promise<void> | ||
| Promise<{ provide?: Record<string, unknown> | undefined }> | ||
| { provide?: Record<string, unknown> | undefined } | ||
|
||
export interface PluginCallbackParameters { | ||
queryClient: QueryClient | ||
} | ||
// "#build/internal.vue-query-plugin-callback will resolve to this file when building the library. | ||
// The actual function will be defined by the user and injected in the .nuxt directory. | ||
// Typescript will resolve this type regardless | ||
|
||
// eslint-disable-next-line unused-imports/no-unused-vars | ||
export const pluginCallback = (pluginCallbackParameters: PluginCallbackParameters): ReturnedByPlugin => ({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { type QueryClient } from "@tanstack/vue-query" | ||
|
||
export type ReturnedByPlugin = | ||
| void | ||
| Promise<void> | ||
| Promise<{ provide?: Record<string, unknown> | undefined }> | ||
| { provide?: Record<string, unknown> | undefined } | ||
|
||
export interface PluginCallbackParameters { | ||
queryClient: QueryClient | ||
} |