I have a class that performs a login request on instantiation, I only want this login request to be performed by the base class and for all other instances to acknowledge that the login has been performed. Can anyone recommend how this can be achieved, would this be a use-case for making the login function static?
// Example
class Content {
constructor() {
this.performLogin()
}
performLogin() { // will making this static achieve my request?
// go fetch if 1st time
// else bypass this step
}
performLogout() {
// perform log out once only
}
}
class ContentOne extends Content {
constructor() {
super()
}
doSomethingElse() {
//...
}
}
class ContentTwo extends Content {
constructor() {
super()
}
alertUser() {
//...
}
}
const contentOne = new ContentOne()
const contentTwo = new ContentTwo()