-
Notifications
You must be signed in to change notification settings - Fork 538
Closed
Description
What problem does this feature solve?
I want to use "return" or (or something different) to stop a script setup code from running.
In the example, the functions should only run if the dynamic list is bigger than 0.
I understand I can invert the ifs, but imagine if we didn't import these functions, but instead, you had to write the code directly. Suddenly you need your whole component's code wrapped around an if when all you can do is prevent the code from running under a specific condition.
What does the proposed API look like?
<script lang="ts" setup>
import dynamicList from 'somewhere';
import { apiRequest, dispatchReportsData, clearUserData, clearCompanyData } from 'somewhere-else';
if (dynamicList.length > 0) {
return; // <-- stop script setup
}
apiRequest();
dispatchReportsData();
clearUserData();
clearCompanyData();
</script>
huang-julien