@@ -16,6 +16,11 @@ export type ContextKey<Z> = InjectionKey<Z> | string
1616 *
1717 * @see https://vuejs.org/api/composition-api-dependency-injection.html#inject
1818 * @see https://0.vuetifyjs.com/composables/foundation/create-context
19+ *
20+ * @example
21+ * ```ts
22+ * const myContext = useContext<MyContext>('my-context')
23+ * ```
1924 */
2025export function useContext < Z > ( key : ContextKey < Z > ) {
2126 const context = inject < Z > ( key , undefined as Z )
@@ -38,6 +43,11 @@ export function useContext<Z> (key: ContextKey<Z>) {
3843 *
3944 * @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
4045 * @see https://0.vuetifyjs.com/composables/foundation/create-context
46+ *
47+ * @example
48+ * ```ts
49+ * provideContext<MyContext>('my-context', myContext)
50+ * ```
4151 */
4252export function provideContext < Z > ( key : ContextKey < Z > , context : Z , app ?: App ) {
4353 app ?. provide ( key , context ) ?? provide ( key , context )
@@ -48,12 +58,17 @@ export function provideContext<Z> (key: ContextKey<Z>, context: Z, app?: App) {
4858/**
4959 * Creates a new context for providing and injecting data.
5060 *
51- * @param _key The key of the context to create.
61+ * @param key The key of the context to create.
5262 * @template Z The type of the context.
5363 * @returns A tuple containing the `useContext` and `provideContext` functions.
5464 *
5565 * @see https://vuejs.org/api/composition-api-dependency-injection.html
5666 * @see https://0.vuetifyjs.com/composables/foundation/create-context
67+ *
68+ * @example
69+ * ```ts
70+ * const [provideMyContext, useMyContext] = createContext<MyContext>('my-context')
71+ * ```
5772 */
5873export function createContext < Z > ( _key : ContextKey < Z > ) {
5974 function _provideContext ( context : Z , app ?: App ) {
0 commit comments