From 90fb83aceb61f087e18da85d4fec0909fa250ecb Mon Sep 17 00:00:00 2001 From: Jules BOURDAIS Date: Wed, 21 Feb 2024 16:33:41 +0100 Subject: [PATCH] fix(dev reload): 17_dev_reload + trame.app.dev clear _change_callbacks from server.state instead of server --- examples/validation/core/17_dev_reload.py | 5 +++-- trame/app/dev.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/validation/core/17_dev_reload.py b/examples/validation/core/17_dev_reload.py index bb8de3c1..bb940893 100644 --- a/examples/validation/core/17_dev_reload.py +++ b/examples/validation/core/17_dev_reload.py @@ -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 @@ -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) diff --git a/trame/app/dev.py b/trame/app/dev.py index c1893049..ee391a2d 100644 --- a/trame/app/dev.py +++ b/trame/app/dev.py @@ -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): @@ -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):