Skip to content

Switch statements for declaring reactive pages #6260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheBlueOompaLoompa opened this issue Apr 29, 2021 · 2 comments
Closed

Switch statements for declaring reactive pages #6260

TheBlueOompaLoompa opened this issue Apr 29, 2021 · 2 comments

Comments

@TheBlueOompaLoompa
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to create a page with multiple login steps, it would be great if I could just use a switch block instead of multiple if blocks.

Describe the solution you'd like

<script>
  var x = 'first'
</script>
{#switch x}
  {:case 'first'}
    <h1>First</h1>
  {:case 'second}
    <h2>Second</h2>
{/switch}

Describe alternatives you've considered
I have tried svelte client side rendering, but that won't work in the current case because I'm using Sveltekit.

How important is this feature to you?
It would be nice but unnecessary, I know a lot of svelte is about being fast, and sleek. This would make the developer experience a lot faster. I have also heard that switch statements are faster than if statements.

Additional context
In this case I just need to switch between small blocks of HTML, so it wouldn't be too much bigger than normal

@pngwn
Copy link
Member

pngwn commented Apr 29, 2021

This is a significant enough feature to require an RFC: https://github.com/sveltejs/rfcs

FWIW, I think this would be a useful feature and plan on putting an RFC together at some point.

@pngwn pngwn closed this as completed Apr 29, 2021
@TheBlueOompaLoompa
Copy link
Author

I made a RFC sveltejs/rfcs#49, you can contribute any changes you may want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants