Tracker comp.firstRun question


#1

My last days experience is that code inside !computation.firstRun clause never run.

Tracker.autorun((computation) => {
if(!computation.firstRun){
    console.log(reactiveVar);
    console.log('I will never get here');
}
});

Could be tracker assumes the code is empty on first run so cancels computation at all (?)


#2

On the first run of your autorun, your reactiveVar is not accessed, so the the dependency is never established, meaning the autorun never re-runs. Change your code so reactiveVar is accessed before the test:

Tracker.autorun(computation => {
  const x = reactiveVar.get(); // establishes dependency.
  if (!computation.firstRun) {
    console.log(x);
  }
});

#3

Thank you for clarifying. It confirms my findings. Sad it’s not stated in the documentation of the firstRun.