Skip to content

Commit

Permalink
fix(dev reload): 17_dev_reload + trame.app.dev
Browse files Browse the repository at this point in the history
clear _change_callbacks from server.state instead of server
  • Loading branch information
bourdaisj authored and jourdain committed Mar 21, 2024
1 parent 817d835 commit 90fb83a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/validation/core/17_dev_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from trame.app import get_server, dev
from trame.widgets import vtk, vuetify
from trame.ui.vuetify import SinglePageLayout
from trame_server import Server

# -----------------------------------------------------------------------------
# Trame setup
Expand All @@ -16,14 +17,14 @@ def reset_resolution():


# Mode A ----------------------------------------------------------------------
def full_reload():
def full_reload(server: Server):
print("=> Reload mode A")
dev.remove_change_listeners(server, "resolution")
dev.reload(sys.modules.get("__main__"))


# Mode B ----------------------------------------------------------------------
def reload_app():
def reload_app(server: Server):
print("=> Reload mode B")
# dev.clear_triggers(app) # Not needed here
dev.clear_change_listeners(server)
Expand Down
6 changes: 3 additions & 3 deletions trame/app/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def clear_change_listeners(server):
:param server: server on which we want to clear the state.change listeners
:type server: trame_server.core.Server
"""
server._change_callbacks.clear()
server.state._change_callbacks.clear()


def remove_change_listeners(server, *names):
Expand All @@ -34,8 +34,8 @@ def remove_change_listeners(server, *names):
:type *names: str
"""
for name in names:
if name in server._change_callbacks:
server._change_callbacks.pop(name)
if name in server.state._change_callbacks:
server.state._change_callbacks.pop(name)


def reload(*reload_list):
Expand Down

0 comments on commit 90fb83a

Please sign in to comment.