feat: computed reactive variables#455
Merged
maartenbreddels merged 2 commits intomasterfrom Feb 9, 2024
Merged
Conversation
This was referenced Jan 10, 2024
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @maartenbreddels and the rest of your teammates on |
eca69f7 to
530c72b
Compare
58fe1a8 to
1e3ab7e
Compare
2a2db1c to
f4e000c
Compare
f4e000c to
fd38bdc
Compare
fd38bdc to
d729d5d
Compare
This was referenced Jan 19, 2024
6e163fd to
0933395
Compare
96720b1 to
fd6ce25
Compare
3e25f02 to
c2c3c95
Compare
0933395 to
a99f167
Compare
c2c3c95 to
0134661
Compare
This was referenced Feb 5, 2024
0134661 to
a2b582f
Compare
a2b582f to
6acaeba
Compare
6acaeba to
5b55459
Compare
bbb7584 to
7bd5707
Compare
* feat: get_kernel_id and get_session_id for custom storage If you want to store data in a custom storage, you need to know the kernel_id or session_id to scope. This can be used to implement something similar to reactive variables.
Creates a reactive variable that is set to the return value of the function.
The value will be updated when any of the reactive variables used in the function
change.
Example:
```solara
import solara
import solara.lab
a = solara.reactive(1)
b = solara.reactive(2)
@solara.lab.computed
def total():
return a.value + b.value
def reset():
a.value = 1
b.value = 2
@solara.component
def Page():
print(a, b, total)
solara.IntSlider("a", value=a)
solara.IntSlider("b", value=b)
solara.Text(f"a + b = {total.value}")
solara.Button("reset", on_click=reset)
```
z.value will be lazily executed the first time, and will be updated
when one of the dependencies changes.
7bd5707 to
7d63ad0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Creates a reactive variable that is set to the return value of the function.
The value will be updated when any of the reactive variables used in the function
change.
Example:
z.value will be lazily executed the first time, and will be updated
when one of the dependencies changes.