Skip to content

Commit

Permalink
debug/test if singleton are never reinstanced
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 8, 2022
1 parent 899a6d3 commit 055d154
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions js/src/services/accordion.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class AccordionService {
constructor() {
if (!this.instance) {
this.instance = this;
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/api.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ApiService {
if (!this.instance) {
this.instance = this;
this.afterSuccessCallbacks = [];
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/data.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class DataService {
this.instance = this;
this.hasStorage = this.storageAvailable('localStorage') && this.storageAvailable('sessionStorage');
this.storage = { session: sessionStorage, local: localStorage };
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/form.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class FormService {
}
});
};
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/modal.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ModalService {
if (!ModalService.instance) {
this.modals = [];
ModalService.instance = this;
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return ModalService.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/panel.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class PanelService {
currentVisibleId: null, // the current panel id that is in a visible state.
currentParams: null, // url argument of the current panel.
};
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/popup.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class PopupService {
constructor() {
if (!PopupService.instance) {
PopupService.instance = this;
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return PopupService.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/upload.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class UploadService {
constructor() {
if (!UploadService.instance) {
UploadService.instance = this;
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return UploadService.instance;
Expand Down
2 changes: 2 additions & 0 deletions js/src/services/vue.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class VueService {
},
};
VueService.instance = this;
} else {
throw 'singleton instanced more than once: ' . this.constructor.name;
}

return VueService.instance;
Expand Down
2 changes: 2 additions & 0 deletions public/atkjs-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,8 @@ class AccordionService {
constructor() {
if (!this.instance) {
this.instance = this;
} else {
throw 'singleton instanced more than once: '.this.constructor.name;
}

return this.instance;
Expand Down
2 changes: 1 addition & 1 deletion public/atkjs-ui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/atkjs-ui.min.js.map

Large diffs are not rendered by default.

0 comments on commit 055d154

Please sign in to comment.