From b8f903f42560a82a50f1202384b804d3cc553883 Mon Sep 17 00:00:00 2001 From: ansbbrooks Date: Mon, 22 Jun 2026 12:28:10 -0500 Subject: [PATCH] feat(vtklocal): Add ability to pass additional data arguments to the LocalView.update() method. Pass one object instead of unwrapping it into multiple arguments. Ensure the "bindCanvas" JS portion still works correctly with the optional data payload. fixed "any" annotation --- src/trame_vtklocal/widgets/vtklocal.py | 5 +++-- vue-components/src/components/VtkLocal.js | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/trame_vtklocal/widgets/vtklocal.py b/src/trame_vtklocal/widgets/vtklocal.py index 9599d77..ea694dd 100644 --- a/src/trame_vtklocal/widgets/vtklocal.py +++ b/src/trame_vtklocal/widgets/vtklocal.py @@ -5,6 +5,7 @@ import warnings import zipfile from pathlib import Path +from typing import Any from trame_client.widgets.core import AbstractElement from trame_common.exec.throttle import Throttle @@ -213,13 +214,13 @@ def update_throttle(self): """ return self._update_throttle - def update(self, push_camera=False): + def update(self, push_camera=False, **kwargs: Any): """Sync view by pushing updates to client""" self.api.update( push_camera=push_camera, obj_to_update=[self._render_window, *self.__registered_obj], ) - self.server.js_call(self.__ref, "update") + self.server.js_call(self.__ref, "update", kwargs) def register_vtk_object(self, vtk_instance): """Register external element (i.e. widget) into the scene so it can be managed and return its wasm_id""" diff --git a/vue-components/src/components/VtkLocal.js b/vue-components/src/components/VtkLocal.js index abf2be1..fba2b06 100644 --- a/vue-components/src/components/VtkLocal.js +++ b/vue-components/src/components/VtkLocal.js @@ -530,7 +530,14 @@ export default { return { container, - update, + async update(){ + // Server.js_call("update") could potentially send a + // payload, so wrap the inner update() function in order + // to control the method signature for the Trame callback. + // This way, payload arguments to the Trame callback do not + // interfere with the internal "bindCanvas" argument. + await update(false); + }, resetCamera, render, evalStateExtract,