I have two classes Foo and Bar.
And propriety of Foo called hello.
Bar is calling a method of Foo using a callback which uses the property hello.
Whenever the value of hello changes in Foo, the value utilized by Bar should synchronize accordingly.
But it doesn't. How can I refactor the below code to achieve this?
  class Foo{
        start(){
            const bar = new Bar()
            bar.start(this.myFooCallback)
            this.hello = 'world'
        }
        myFooCallback(){
            console.log(this.hello)
        }
    }
    class Bar{
        start(cb){
            setInterval(()=>{
                cb()
            },1000)
        }
    }
    
    const foo = new Foo()
    foo.start() 
    