The reactive session object
We've seen that the session object can rerun a function when its value is changed. This is the same behavior as that of the find()
and findOne()
functions of collections, which will rerun functions when the underlying data in the collection changes.
We can use sessions to keep user states across hot code pushes, such as states of drop-down menus or pop-ups. However, keep in mind that without a clear naming convention, these session variables can soon become hard to maintain.
For more specific reactive behavior, it is good to build a custom reactive object using Meteor's Tracker
core package, which we will cover in Chapter 9, Advanced Reactivity.