Skip to content

Stop script setup from executing any further #574

@bediu

Description

@bediu

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions