From 6b5e79be78d174537f194debcde07d736b405293 Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Sun, 21 Apr 2019 06:18:43 -0400 Subject: [PATCH] Added table ownership flag to `` `delete()` method --- packages/perspective-viewer/src/js/viewer.js | 6 ++++-- .../perspective-viewer/src/js/viewer/perspective_element.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/perspective-viewer/src/js/viewer.js b/packages/perspective-viewer/src/js/viewer.js index f1bfde584c..8e61204409 100755 --- a/packages/perspective-viewer/src/js/viewer.js +++ b/packages/perspective-viewer/src/js/viewer.js @@ -457,11 +457,13 @@ class PerspectiveViewer extends ActionElement { * user state). This (or the underlying `perspective.table`'s equivalent * method) must be called in order for its memory to be reclaimed. * + * @param {boolean} delete_table Should a delete call also be made to the + * underlying `table()`. * @returns {Promise} Whether or not this call resulted in the * underlying `perspective.table` actually being deleted. */ - delete() { - let x = this._clear_state(); + delete(delete_table = true) { + let x = this._clear_state(delete_table); if (this._plugin.delete) { this._plugin.delete.call(this); } diff --git a/packages/perspective-viewer/src/js/viewer/perspective_element.js b/packages/perspective-viewer/src/js/viewer/perspective_element.js index 8199d4c29a..e6e916ad63 100644 --- a/packages/perspective-viewer/src/js/viewer/perspective_element.js +++ b/packages/perspective-viewer/src/js/viewer/perspective_element.js @@ -312,7 +312,7 @@ export class PerspectiveElement extends StateElement { return () => this.setAttribute("render_time", performance.now() - t); } - _clear_state() { + _clear_state(clear_table = true) { if (this._task) { this._task.cancel(); } @@ -324,7 +324,7 @@ export class PerspectiveElement extends StateElement { view.remove_update(this._view_updater); view.remove_delete(); } - if (this._table) { + if (this._table && clear_table) { const table = this._table; this._table = undefined; if (table._owner_viewer && table._owner_viewer === this) {