Meteor Tutorial
Meteor Useful Resources
Selected Reading
- Meteor - Best Practices
- Meteor - ToDo App
- Meteor - Running on mobile
- Meteor - Deployment
- Meteor - Structure
- Meteor - Publish & Subscribe
- Meteor - Package.js
- Meteor - Methods
- Meteor - Accounts
- Meteor - Sorting
- Meteor - Security
- Meteor - Assets
- Meteor - Email
- Meteor - HTTP
- Meteor - EJSON
- Meteor - Timers
- Meteor - Blaze
- Meteor - Check
- Meteor - Core API
- Meteor - Packages
- Meteor - Tracker
- Meteor - Session
- Meteor - Events
- Meteor - Forms
- Meteor - Collections
- Meteor - Templates
- Meteor - First Application
- Meteor - Environment Setup
- Meteor - Overview
- Meteor - Home
Meteor Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Meteor - Tracker
Meteor - Tracker
Tracker is a small pbrary used for auto updating templates once the Session variable has changed. In this chapter, we will learn how the tracker works.
First, we will create a button that will be used for updating the session.
meteorApp.html
<head> <title>meteorApp</title> </head> <body> <span> {{> myTemplate}} </span> </body> <template name = "myTemplate"> <button id = "myButton">CLICK ME</button> </template>
Next, we will set the starting session value myData and create a mySession object. Tracker.autorun method is used for keeping an eye on mySession. Whenever this object changes, the template will auto-update. To test it, we will set a cpck event for updating.
meteorApp.js
if (Meteor.isCpent) { var myData = 0 Session.set( mySession , myData); Tracker.autorun(function () { var sessionData = Session.get( mySession ); console.log(sessionData) }); Template.myTemplate.events({ cpck #myButton : function() { Session.set( mySession , myData ++); } }); }
If we cpck the CLICK ME button five times, we will see that the tracker is logging new values every time the session updates.
![Meteor Tracker Log](/meteor/images/meteor-tracker-log.jpg)