Allow reactivity inside functions
See original GitHub issueWhen I use a function inside my template, eg <p>{getUserName()}</p>
, and getUserName()
is using a reactive variable, the template is not updated when the reactive variable changes. I guess this is due to the compiler not analyzing the function and looking which variables it depends on. But, if I use an inline function inside the template (as demonstrated in the below), it updates just fine.
https://svelte.dev/repl/df444c2dfa5240ae9c8c203aaabdcd61?version=3.9.1
How hard would it be to add this feature?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Chapter 3 Basic reactivity | Mastering Shiny
Reactive expressions are important because they give Shiny more information so that it can do less recomputation when inputs change, making apps more...
Read more >Use reactive expressions - R Shiny - RStudio
This lesson will show you how to streamline your Shiny apps with reactive expressions. Reactive expressions let you control which parts of your...
Read more >5 Reactive functions | Building Web Apps with R Shiny
5.2 reactive() This means that whenever an input inside that function changes, the code will run and update the value of data() ....
Read more >How does Svelte reactivity work inside functions?
I have isolated what I think is at least one of my main issues. When bind:ing a variable to a checkbox, the reactivity...
Read more >The Magic Behind Reactivity - Effects - Ryan Chandler
In this post, I'll be creating an effect function that will allow us to react to changes on the Proxy and update the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@PaulMaly wow, thanks for that. I guess that solves this issue in a “sufficiently elegant” way 😃
@buhrmi Please check workaround for this feature: https://svelte.dev/repl/39fcb67d8041423e84d7c08da75b05de?version=3.9.1
Basically, you can think about regular function call inside of your template as about
pull reactivity
and reactive declarations aspush reactivity
. Both methods we need in some cases.