Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev reload): 17_dev_reload + trame.app.dev #456

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading