Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Can you provide more context? What was |
|
@Justineo My request is not about Neglible: Also I don't like the empty assignment in the compiled code As for I prefer individual event functions to keep the usage symetrical between the publishing side and the consumer side: ComponentA: const { onValidChanged } = splitEmitFunctions(defineEmits<{ onValidChanged: [valid: boolean] }>());
// const emit = defineEmits<{ onValidChanged: [valid: boolean] }>();
// const onValidChanged: (valid : boolean) => void = (value) => emit('onValidChanged ', value);
watch(valid, (value) -> onValidChanged(value))ComponentB: <script setup lang="ts">
const onValidChanged: (valid: boolean) => void = (value) => continue.disabled = value;
</script>
<template>
<ComponentA @onValidChanged="onValidChanged" />
</template>So that: ComponentA's ComponentA: const { onValidChanged } = splitEmitFunctions(defineEmits<{ onValidChanged: OnValueChanged }>());ComponentB: <script setup lang="ts">
const onValidChanged: OnValueChanged = (value) => continue.disabled = value;
</script>But you could also use it for different usecases such as simplified debug logging: function logToConsole<T>(emit: T): T {
return (...args) => {
console.log("Event", ...args);
emit(...args);
}
}const emit = logToConsole(defineEmits<{ onValidChanged: [valid: boolean] }>());
watch(valid, (value) -> emit('onValidChanged ', value)) |
I'm not sure whether this is a fix or a feature.
This PR allows calling
defineEmitsas an argument of another method.My Usecase
splitEmitFunctionsdefinitionWithout this patch, you have to use the following code:
poluting the scope with the
emitvariable, that shouldn't be used after this.