Support for hot-reload... #231
jourdain
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since
trame-server>=2.8.0
trame support dynamic file reloading.Q: What does it mean for you?
A: That means you can dynamically edit your code base and re-execute it without stoping and/or restarting your server.
Q: How does it work?
A: Any method attached to the
controller
or astate.change
will reload from disk at each execution. Needs to be triggered by thecontroller.my_method()
or@state.change(...)
decoration.Q: How do I enable it while developing?
A: You can either set the environment variable
TRAME_HOT_RELOAD=1
or add a CLI arg--hot-reload
orserver.hot_reload = True
Q: What if I want to reload a function/method that is outside of the controller or state.change?
A: You can use our
@hot_reload
annotation (from trame_server.utils.hot_reload import hot_reload
).Q: Is there any limitation?
A: Yes, especially with closure functions. But instance methods works great.
Q: Is there a reference example that I can play with?
A: Yes and it is available in 17_hot_reload.py
Q: Can I use it when tweaking the UI?
A: Absolutely. You just need to encapsulate your layout definition inside a function/method. Then either attach it to the
controller.on_server_reload
which will add a refresh button in the footer of thevuetify.ui.*
. Or bind it to your own button.Beta Was this translation helpful? Give feedback.
All reactions