Skip to content
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

feat: reactive_task decorator (re)runs a task when a dependency changes #473

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maartenbreddels
Copy link
Contributor

Dependencies are other reactive variables.

Examples:

import asyncio
import time
import solara
from solara.lab import reactive_task

x = solara.reactive(2)

@reactive_task
async def x_square():
    await asyncio.sleep(2)
    a = b
    return x.value**2

@solara.component
def Page():
    solara.SliderInt("x", value=x, min=0, max=10)
    if x_square.value.state == solara.ResultState.FINISHED:
        solara.Text(repr(x_square.value.value))
    solara.ProgressLinear(x_square.value.state == solara.ResultState.RUNNING)

@maartenbreddels maartenbreddels force-pushed the 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution branch from 7288e79 to 86758cc Compare January 19, 2024 19:42
@maartenbreddels maartenbreddels force-pushed the 01-19-feat_reactive_task_decorator_re_runs_a_task_when_a_dependency_changes branch from 1cfa556 to f0c7455 Compare January 19, 2024 19:42
@iisakkirotko iisakkirotko force-pushed the 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution branch from 86758cc to 06c4657 Compare February 5, 2024 13:36
@iisakkirotko iisakkirotko force-pushed the 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution branch 3 times, most recently from 899a669 to 850c94b Compare February 8, 2024 16:14
@maartenbreddels maartenbreddels force-pushed the 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution branch 7 times, most recently from 1f4fc86 to d39063b Compare February 14, 2024 16:50
@maartenbreddels maartenbreddels force-pushed the 01-19-feat_reactive_task_decorator_re_runs_a_task_when_a_dependency_changes branch from f0c7455 to f0b4019 Compare February 14, 2024 16:50
@maartenbreddels maartenbreddels force-pushed the 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution branch 8 times, most recently from f981cfd to a9f836f Compare February 16, 2024 13:34
Dependencies are other reactive variables.

Examples:

```
import asyncio
import time
import solara
from solara.lab import reactive_task

x = solara.reactive(2)

@reactive_task
async def x_square():
    await asyncio.sleep(2)
    a = b
    return x.value**2

@solara.component
def Page():
    solara.SliderInt("x", value=x, min=0, max=10)
    if x_square.value.state == solara.ResultState.FINISHED:
        solara.Text(repr(x_square.value.value))
    solara.ProgressLinear(x_square.value.state == solara.ResultState.RUNNING)
```
@maartenbreddels maartenbreddels force-pushed the 01-19-feat_reactive_task_decorator_re_runs_a_task_when_a_dependency_changes branch from f0b4019 to 3760636 Compare March 10, 2024 21:23
@maartenbreddels maartenbreddels changed the base branch from 01-12-feat_task_and_use_task_for_better_asyncio_task_a_thread_execution to master March 10, 2024 21:23
@iisakkirotko iisakkirotko force-pushed the master branch 2 times, most recently from c2951b9 to 8816e36 Compare April 5, 2024 14:59
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

Successfully merging this pull request may close these issues.

None yet

1 participant