I would like to know your opinion which is the best way to do that:
I have two classes:
class Application {
...
pause() {}
resume() {}
...
}
(Just image that the Application class is a big one. Which has a lot of methods and properties.)
class System {
constructor(app: Application) {
this.pauseCallback = app.pause.bind(app)
this.resumeCallback = app.resume.bind(app)
}
onWindowInactive() {
this.pauseCallback()
}
onWindowActive() {
this.resumeCallback()
}
}
The reason why I'm using .bind function on these methods is because I don't want to assign a reference to Application class in System class. So, I can do like this.app.pause() but I don't want to do that.
Instead of this I'm creating new functions using .bind and assigning them to System class properties. Then I can use pause and resume methods of Application
Is that the correct way to do that and what about performance and memory allocation?