Skip to content

Commit

Permalink
Add subscription disposal to component
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Oct 9, 2023
1 parent 74e95ac commit e961405
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions js/components/circe/components/ConceptSetBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
], function (ko, template, VocabularyProvider, appConfig, ConceptSet, authApi, datatableUtils, commonUtils) {
function CohortConceptSetBrowser(params) {
var self = this;
var subscriptions = [];

function defaultRepositoryConceptSetSelected(conceptSet, source) {
// Default functionality
Expand Down Expand Up @@ -132,11 +133,13 @@ define([
if (self.isComponentUsedAsModal()) {
// Add subscription to load concept set
// list when the modal is displayed
self.showModal.subscribe(() => {
if (self.showModal()){
self.loadConceptSetsFromRepository(self.selectedSource().url);
}
});
subscriptions.push(
self.showModal.subscribe(() => {
if (self.showModal()){
self.loadConceptSetsFromRepository(self.selectedSource().url);
}
})
);
} else {
// startup actions
self.loadConceptSetsFromRepository(self.selectedSource().url);
Expand Down Expand Up @@ -188,6 +191,10 @@ define([
render: datatableUtils.getCreatedByFormatter(),
}
]);

self.dispose = () => {
subscriptions.forEach(sub => sub.dispose());
}

const { pageLength, lengthMenu } = commonUtils.getTableOptions('M');
this.pageLength = params.pageLength || pageLength;
Expand Down

0 comments on commit e961405

Please sign in to comment.