diff --git a/js/widget.js b/js/widget.js index 8be72e91..3a181efc 100644 --- a/js/widget.js +++ b/js/widget.js @@ -190,7 +190,7 @@ function render({ model, el }) { aladin.getOverlayImageLayer().setAlpha(model.get("overlay_survey_opacity")); }); - model.on("msg:custom", (msg) => { + model.on("msg:custom", (msg, buffers) => { let options = {}; switch (msg["event_name"]) { case "goto_ra_dec": @@ -232,7 +232,7 @@ function render({ model, el }) { aladin.select(); break; case "add_table": - let table_bytes = model.get("_table"); + let table_bytes = buffers[0].buffer; let decoder = new TextDecoder("utf-8"); let blob = new Blob([decoder.decode(table_bytes)]); let url = URL.createObjectURL(blob); @@ -259,7 +259,6 @@ function render({ model, el }) { model.off("change:overlay_survey"); model.off("change:overlay_survey_opacity"); model.off("change:trigger_event"); - model.off("change:_table"); model.off("msg:custom"); aladin.off("positionChanged"); diff --git a/src/ipyaladin/__init__.py b/src/ipyaladin/__init__.py index 6c9fbe99..d589fd18 100644 --- a/src/ipyaladin/__init__.py +++ b/src/ipyaladin/__init__.py @@ -13,9 +13,7 @@ List, Dict, Any, - Bytes, default, - Undefined, ) from .coordinate_parser import parse_coordinate_string @@ -87,9 +85,6 @@ class Aladin(anywidget.AnyWidget): overlay_survey = Unicode("").tag(sync=True, init_option=True) overlay_survey_opacity = Float(0.0).tag(sync=True, init_option=True) - # tables/catalogs - _table = Bytes(Undefined).tag(sync=True) - init_options = List(trait=Any()).tag(sync=True) @default("init_options") @@ -300,8 +295,10 @@ def add_table(self, table, **table_options): table_bytes = io.BytesIO() table.write(table_bytes, format="votable") - self._table = table_bytes.getvalue() - self.send({"event_name": "add_table", "options": table_options}) + self.send( + {"event_name": "add_table", "options": table_options}, + buffers=[table_bytes.getvalue()], + ) def add_overlay_from_stcs(self, stc_string, **overlay_options): """Add an overlay layer defined by a STC-S string.