Skip to content
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
3 changes: 3 additions & 0 deletions docs/perspective-viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ Resotre this element to a state as generated by a reciprocal call to

- `x` **[object][26]** returned by `save`.

Returns **[Promise][29]<void>** A promise which resolves when the changes have
been applied.

### reset

Reset's this element's view state and attributes to default. Does not
Expand Down
3 changes: 3 additions & 0 deletions packages/perspective-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ Resotre this element to a state as generated by a reciprocal call to

- `x` **[object][26]** returned by `save`.

Returns **[Promise][29]<void>** A promise which resolves when the changes have
been applied.

### reset

Reset's this element's view state and attributes to default. Does not
Expand Down
11 changes: 9 additions & 2 deletions packages/perspective-viewer/src/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,18 @@ class View extends ViewPrivate {
* `save`.
*
* @param {object} x returned by `save`.
* @returns {Promise<void>} A promise which resolves when the changes have
* been applied.
*/
restore(x) {
async restore(x) {
for (let key in x) {
this.setAttribute(key, x[key]);
let val = x[key];
if (typeof val !== "string") {
val = JSON.stringify(val);
}
this.setAttribute(key, val);
}
await this._debounce_update();
}

/**
Expand Down