import time
from datetime import datetime
import solara
import asyncio
@solara.component
def TimerComponent():
reactive_text = solara.use_reactive("")
print(f"Timer Component Update: {reactive_text.value}")
async def _increment_counter():
while True:
reactive_text.value = datetime.now().strftime("%Y-%m-%D %H:%M:%S")
await asyncio.sleep(1)
solara.Text(text=reactive_text.value)
solara.lab.use_task(_increment_counter, dependencies=[])
@solara.component
def InputComponent():
v1, set_v1 = solara.use_state(1)
reactive_int_2 = solara.use_reactive(2)
v3, set_v3 = solara.use_state(3)
print(f"Input Component Update: {v1}, {reactive_int_2.value}")
solara.InputInt(label="Input 1", value=v1, on_value=set_v1) # will overwrite with the current value
solara.InputInt(label="Input 2", value=reactive_int_2) # same
solara.v.TextField(v_model=v3, on_v_model=set_v3)
@solara.component
def Page():
TimerComponent()
InputComponent()
Page()