Is on_mount guaranteed to be called just once? #3960
-
|
Hello! Excited to be learning textual. Quick question I didn't see covered in the docs: Is on_mount on an App guaranteed to be called just once? Or might it get called a second time, e.g. when a tmux session is resumed or the app is backgrounded and then foregrounded again? I'm trying to figure out where to put setup code that should run just once. I think on_mount is the right place, but maybe it's __init__ 🤷 . Also, let me know if this is the right forum to ask questions like this, or if I should instead head to stackoverflow or some other location. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The mount message is sent once, so You could also put simple setup code in the constructor, if it doesn't need to do queries. |
Beta Was this translation helpful? Give feedback.
The mount message is sent once, so
on_mountis generally the best place to do any setup code that requires the DOM to be ready.You could also put simple setup code in the constructor, if it doesn't need to do queries.