types: using InjectionKey in composables (#8976)

This commit is contained in:
neverland 2021-07-04 23:04:54 +08:00 committed by GitHub
parent 5c080f3a6e
commit 8bc924ea62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -1,13 +1,10 @@
import { inject, watch } from 'vue';
import { inject, InjectionKey, watch } from 'vue';
// eslint-disable-next-line
export const POPUP_TOGGLE_KEY = Symbol();
export const POPUP_TOGGLE_KEY: InjectionKey<() => boolean> = Symbol();
export function onPopupReopen(callback: () => void) {
const popupToggleStatus = inject<(() => boolean) | null>(
POPUP_TOGGLE_KEY,
null
);
const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
if (popupToggleStatus) {
watch(popupToggleStatus, (show) => {

View File

@ -1,8 +1,8 @@
import { inject, ComputedRef } from 'vue';
import { inject, ComputedRef, InjectionKey } from 'vue';
// eslint-disable-next-line
export const TAB_STATUS_KEY = Symbol();
export const TAB_STATUS_KEY: InjectionKey<ComputedRef<boolean>> = Symbol();
export function useTabStatus() {
return inject<ComputedRef<boolean> | null>(TAB_STATUS_KEY, null);
return inject(TAB_STATUS_KEY, null);
}