T
T
Tyler Lowell2020-08-03 18:52:49
JavaScript
Tyler Lowell, 2020-08-03 18:52:49

How to track all class calls with parent class?

Good evening. There is, for example, a class First , which is inherited from Second :

class Second {
    m_Name = 'Module'
    m_State = true

    constructor(name) {
        this.m_Name = name
    }

    turnState(value = !this.m_State) {
        this.m_State = value
    }
}

class First extends Second {
    constructor() {
        super('First')
    }
}


And I, for example, want each "heir" of the Second class to have the ability to change the state (true - works, false - does not work). That is, if the "successor" state is false , then all its calls will return null . So. How can Second trace the call to First?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question