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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export const DataLoaderBehavior = {
* An unique identifiable string. When changes, it expunges the data
* cache.
*/
loadKey: String,
loadKey: {
type: String,
value: '',
},

// List of data to be loaded. A datum is passed to `getDataLoadUrl` to ge
// URL of an API endpoint and, when request resolves, invokes
Expand Down Expand Up @@ -80,7 +83,6 @@ export const DataLoaderBehavior = {
},

observers: [
'_loadKeyChanged(loadKey)',
'_dataToLoadChanged(isAttached, dataToLoad.*)',
],

Expand All @@ -93,10 +95,12 @@ export const DataLoaderBehavior = {
this._loadData();
},

_loadKeyChanged(_) {
// When `key` changes, cancel all handlers from the previous requests.
this._canceller.cancelAll();
this._loadedData.clear();
reset() {
// https://github.com/tensorflow/tensorboard/issues/1499
// Cannot use the observer to observe `loadKey` changes directly.
if (this._canceller) this._canceller.cancelAll();
if (this._loadedData) this._loadedData.clear();
if (this.isAttached) this._loadData();
},

_dataToLoadChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
},

_loadKeyChanged(_) {
this.reset();
this._resetDomainOnNextLoad = true;
},

Expand Down