Rerun the script immediately.
When Jt.rerun()
is called, Jeamlit halts the current app run and executes no further statements. Jeamlit immediately
queues the script to rerun. In a multipage app: by default, the rerun is for the same url path (same page). If the rerun could make
the current page unavailable, pass toHome = true
to send back to the home url and avoid 404 errors.
Method Signatures and Parameters | |
Jt.rerun(boolean toHome) | toHome (boolean) If |
Jt.rerun() |
Examples
Updating session state and triggering rerun
import io.jeamlit.core.Jt;
public class RerunApp {
public static void main(String[] args) {
Jt.sessionState().computeIfAbsent("value", "Title");
// Display current value
Jt.title(Jt.sessionState().getString("value")).use();
if (Jt.button("Foo").use()) {
Jt.sessionState().put("value", "Foo");
Jt.rerun(false);
}
}
}
Caveats for Jt.rerun
Jt.rerun
is one of the tools to control the logic of your app. While it is great for prototyping, there can be adverse side effects:
- Additional app runs may be inefficient and slower.
- Excessive reruns may complicate your app's logic and be harder to follow.
- If misused, infinite looping may crash your app.
In many cases where Jt.rerun
works, callbacks may be a cleaner alternative.
Containers may also be helpful.
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.