|
1 | 1 | // Types
|
2 | 2 | import type { App, Ref } from 'vue'
|
3 | 3 |
|
4 |
| -export type ContextTrinity<Z = unknown, E = unknown> = readonly [ |
| 4 | +export type ContextTrinity< |
| 5 | + Z = unknown, |
| 6 | + E = unknown, |
| 7 | +> = readonly [ |
5 | 8 | () => Z,
|
6 | 9 | (model?: Ref<E>, context?: Z, app?: App) => Z,
|
7 | 10 | Z,
|
8 | 11 | ]
|
9 | 12 |
|
10 | 13 | /**
|
11 |
| - * Converts individual composable parts to a standardized context trinity pattern. |
12 |
| - * This utility abstracts the common pattern of returning [createContext, provideContext, context]. |
| 14 | + * A tuple containing Vue's provide/inject and a context object |
| 15 | + * @param createContext The function that creates the context |
| 16 | + * @param provideContext The function that provides context |
| 17 | + * @param context The underlying context object singleton |
| 18 | + * @template Z The type parameter for the context value |
| 19 | + * @template E The vmodel type for the context state. |
| 20 | + * @returns [createContext,provideContext,context] |
13 | 21 | *
|
14 |
| - * @param createContext The context hook function |
15 |
| - * @param provideContext The underlying context provider function |
16 |
| - * @param context The context object |
17 |
| - * @template Z The context type |
18 |
| - * @template E The model type |
19 |
| - * @returns A trinity containing [createContext, provideContext, context] |
| 22 | + * @see https://0.vuetifyjs.com/composables/foundation/create-trinity |
20 | 23 | */
|
21 |
| -export function createTrinity<Z = unknown, E = unknown> ( |
| 24 | +export function createTrinity< |
| 25 | + Z = unknown, |
| 26 | + E = unknown, |
| 27 | +> ( |
22 | 28 | createContext: () => Z,
|
23 | 29 | provideContext: (model?: Ref<E>, _context?: Z, app?: App) => Z,
|
24 | 30 | context: Z,
|
|
0 commit comments