veliovgroup / Meteor-flow-router-title

Change document.title on the fly within flow-router
https://atmospherejs.com/ostrio/flow-router-title
BSD 3-Clause "New" or "Revised" License
25 stars 4 forks source link

Possible fix #12 #13

Closed afrokick closed 5 years ago

afrokick commented 5 years ago

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

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.