reactive.invalidate_later(delay, *, session=MISSING)

Scheduled Invalidation

When called from within a reactive context, invalidate_later schedules the reactive context to be invalidated in the given number of seconds.


delay: float

The number of seconds to wait before invalidating.


When called within a reactive function (i.e., effect, calc,, 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.


#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400

## file:
import random

from shiny import reactive
from import render

def value():
    return "Random int: " + str(random.randint(0, 10000))