0👍
✅
The only thing that changes is the name
, the toggleNotif
, and the type
, so use arguments to handle those cases:
handle(method, type, name) {
if (!this.hasPerms()) {
return;
}
if (!!this.loggedInUser) {
this[method]({
notifName: name,
newAnalytics: {
type,
true,
},
});
} else {
login.redir('new');
}
},
Then call, eg, handle('toggleNotif', 'brand', someName)
or handle('toggleAllNotif', 'allBrand')
.
Source:stackexchange.com