reactive.invalidate_later
*, session=MISSING) reactive.invalidate_later(delay,
Scheduled Invalidation
When called from within a reactive context, invalidate_later
schedules the reactive context to be invalidated in the given number of seconds.
Parameters
delay : float
-
The number of seconds to wait before invalidating.
Note
When called within a reactive function (i.e., effect
, calc
, shiny.express.render.ui
, etc.), that reactive context is invalidated (and re-executes) after the interval has passed. The re-execution will reset the invalidation flag, so in a typical use case, the object will keep re-executing and waiting for the specified interval. It’s possible to stop this cycle by adding conditional logic that prevents the invalidate_later
from being run.
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
import random
from shiny import reactive
from shiny.express import render
@render.text
def value():
reactive.invalidate_later(0.5)
return "Random int: " + str(random.randint(0, 10000))