I have a button that can handle both short and long press events.
Before transitioning to emitters, I relied on function callbacks due to my background in React Native.
The typings I used were:
export type UsePressableEmits =
| {
(e: "press", event: Event): void;
(e: "longPress", event: Event): void;
}
| {
(e: "press", event: Event): void;
};
However, the following code block is currently throwing errors:
function fire(event: Event) {
firing.value = true;
emit("press", event);
firing.value = false;
}
function fireLongPress(event: Event) {
firing.value = true;
emit("longPress", event); // does not pass type checks
firing.value = false;
}
The emit
function I am using is generated from:
const emit = defineEmits<{
(e: "press", event: Event): void;
(e: "longPress", event: Event): void;
}>()