Reactive dictionary does not fire tracker if used inside class method


#1

Have a problem making ReactiveDict firing the Tracker.autorun

export class myTest {
constructor() {
this.mapInstance;  <<  googleMapsObject;
this.state = new ReactiveDict();

Tracker.autorun(() => {
         Meteor.subscribe('xxx', this.state.get('mapBox')); <<never called
});
}

    //code edited to reflect the problem - otherMethod() removed

    this.mapInstance.instance.addListener('dragend', () => {
        this.state.set('mapbox', this.getBox());
    });

    getBox ()
     { 
      return ['geoJason box like region definition array here'];
    }
}

I know it’s something about binding.this … but can some explain more the ‘bind it’ ??


#2

Where are you calling otherMethod? Are there any errors in the console?


#3

I edited the code so it reflects the problem in more details.
Former otherMethod is a callback for google map listeners.

  • callback is being called on mouseClick (listener is working)
  • mapBox key is set by callback using this.GetBox() method.
  • there are no errors.

#4

It’s solved, it failed in other place but Tracker inactivity was covered by !c.firstRun. Once removed Tracker is running.