Special tag {@run ...} #13325
phcoliveira
started this conversation in
Ideas
Replies: 2 comments 15 replies
-
Hello, I have trouble seeing the point of such syntax, but you can do this : {#if somethingIsTrue}
<!-- show something -->
{:else}
{goto('/somewhere-else')}
{/if} |
Beta Was this translation helpful? Give feedback.
4 replies
-
I don't think it's a good idea to have side effects in the template, it is not intended for that. |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello folks.
SolidJs has a very useful component:
<Navigation />
. With it, we can programatically navigate to another route in the template.While it is easy to implement such a component on Svelte, I thought of something more general.
Consider this:
However, I usually enable loading in an app-wide system using
beforeNavigate()
andafterNavigate()
. Also, I handle the error in a hook.I cannot simply
{#await goto()}
.An alternative would be to use
$effect()
.However, such effect would not be necessary with an analogous
Navigate
component. But why limit ourselves with just navigation? We could invoke a function in the template, in a similar manner that{{did-insert-helper ...}}
does for Ember.This new special tag would invoke the function without producing any content. That's it.
Beta Was this translation helpful? Give feedback.
All reactions