Also, the original code would have worked with a @ui.in_background decorator. Nothing in a callback shows up until the method ends and control is returned to the ui thread. Though the issue with in_background is that all such calls are queued up on the same thread, so if you tapped the button 20 times in a row, it would take many seconds to toggle through all of these.

In this case it probably does not matter, but in some cases you might want a ui.cancel_all_delays() at the start of button_tapped, o avoid calling the end method 20 times.