Meteor.setTimeout(function(){
console.log("Timeout called after three seconds..."); }, 3000);


meteorApp/client/app.html
<head>
<title>meteorApp</title>
</head>
<body>
<div>
{{> myTemplate}}
</div>
</body>
<template name = "myTemplate">
<button>CLEAR</button>
</template>
meteorApp/client/app.js
if (Meteor.isClient) {
var counter = 0;
var myInterval = Meteor.setInterval(function(){
counter ++
console.log("Interval called " + counter + " times...");
}, 3000);
Template.myTemplate.events({
'click button': function(){
Meteor.clearInterval(myInterval);
console.log('Interval cleared...')
}
});
}
控制臺(tái)將每三秒鐘記錄更新計(jì)數(shù)器- counter 變量。我們可以通過(guò)點(diǎn)擊 CLEAR 按鈕清除。這將調(diào)用 clearInterval 方法。
