本文整理汇总了TypeScript中timer.clearTimeout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clearTimeout函数的具体用法?TypeScript clearTimeout怎么用?TypeScript clearTimeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearTimeout函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
moveToRandomArticleLink: function() {
// Reset our timeout so it'll run again on next load
clearTimeout(this.changePageTimeout);
this.changePageTimeout = null;
let allLinksResponse = this.webview.stringByEvaluatingJavaScriptFromString(`
window.onerror = function(err) {alert(err)};
(function() {
var allArticleLinks = document.querySelectorAll('a[href^="/2016"]');
return JSON.stringify(Array.prototype.slice.call(allArticleLinks).map(function(a) {
return a.href;
}));
})();
`);
let parsedAllLinks = JSON.parse(allLinksResponse);
// Some pages don't have any links on them, so we keep a cache of all the article links
// we find, then select from them.
for (let link of parsedAllLinks) {
if (this.availableLinks.indexOf(link) === -1) {
this.availableLinks.push(link);
}
}
let indexToSelect = Math.floor(Math.random() * this.availableLinks.length);
let [removedLink] = this.availableLinks.splice(indexToSelect, 1);
console.log("Sending to", removedLink);
this.webview.stringByEvaluatingJavaScriptFromString(`window.location = '${removedLink}'`);
},
示例2: function
}, function (error: Error) {
console.error('Location error received: ' + error);
locationManager.stopLocationMonitoring();
if ("undefined" !== typeof timerId) {
timer.clearTimeout(timerId);
}
reject(error);
},
示例3: resolve
locationManager.startLocationMonitoring(function (location: defModule.Location) {
if (options && ("number" === typeof options.maximumAge)) {
if (location.timestamp.valueOf() + options.maximumAge > new Date().valueOf()) {
locationManager.stopLocationMonitoring();
if ("undefined" !== typeof timerId) {
timer.clearTimeout(timerId);
}
resolve(location);
}
}
else {
locationManager.stopLocationMonitoring();
if ("undefined" !== typeof timerId) {
timer.clearTimeout(timerId);
}
resolve(location);
}
}, function (error: Error) {
示例4: function
moveToRandomArticleLink: function() {
// Reset our timeout so it'll run again on next load
clearTimeout(this.changePageTimeout);
this.changePageTimeout = null;
this.webview.stringByEvaluatingJavaScriptFromString(`
(function() {
var allArticleLinks = document.querySelectorAll('a[href^="/2016"]');
var selectedLink = allArticleLinks[Math.floor(Math.random() * allArticleLinks.length)];
window.location = selectedLink.href;
})();
`)
},