onInvalidate registers a one-time callback that either fires immediately or as soon as the computation is next invalidated or stopped. It is used by reactive data sources to clean up resources or break dependencies when a computation is rerun or stopped.
The advice from MDG is
To get a callback after a computation has been recomputed, you can call Tracker.afterFlush from onInvalidate.
But I fixed it another way, it should work properly.
I tried to fix issue https://github.com/VeliovGroup/Meteor-flow-router-title/issues/12
The problem is the computation was run only once.
From docs: https://docs.meteor.com/api/tracker.html#Tracker-Computation-onInvalidate
The advice from MDG is
But I fixed it another way, it should work properly.