Ben Lin
2024-10-22 78999ce1626d2a786f3a705281eeba79c2f1d6dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import type { InjectionKey } from 'vue';
import { createContext, useContext } from '@/hooks/core/useContext';
 
export interface FormContextProps {
  resetAction: () => Promise<void>;
  submitAction: () => Promise<void>;
}
 
const key: InjectionKey<FormContextProps> = Symbol();
 
export function createFormContext(context: FormContextProps) {
  return createContext<FormContextProps>(context, key);
}
 
export function useFormContext() {
  return useContext<FormContextProps>(key);
}