I am writing a calculator program.
class Main
{
constructor()
{
this.calculator = new Calculator // here I do my calculations
this.view = new View(this.calculator) // <-- watch this
this.keyboard = new Keyboard // here I have some event listeners and other fun stuff
}
}
After user clicking on the button, I have to rerender the view. But for this I need to know the result of math operation. I can't call the calculator methods directly in View class, so I passed the calculator object as an argument. Is this normal practice?
Please show me what other ways exist to exchange information between objects?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/IkPEmUo
Comments
Post a Comment