get_state, set_state = mo.state(False) def wait_for_switch() -> bool: while True: if get_state(): return True switch = mo.ui.switch(on_change=set_state)
wait_for_switch()
mo.ui.run_button
? or mo.stop()
? those may be able to help you achieve the same thing, but use some lower-level internal APIs so to no create an infinite loop