concept timer in category javascript

appears as: timer, timer, The timer, timers
JavaScript on Things: Hacking hardware for web developers

This is an excerpt from Manning's book JavaScript on Things: Hacking hardware for web developers.

Figure 5.17. Wiring diagram of timer including potentiometer and LCD placement
Programming the timer’s logic

Our LCD circuitry is ready. It’s time to program the timer. We’ll break this down into chunks, but an overview of the timer’s eventual structure is shown here.

Listing 5.17. Overview of timer application structure

Jumping in from the top, a section of variable initialization sets up some of the values we’ll need for operating the timer, as shown in the following listing. Add these to timer-advanced.js.

Listing 5.18. Setting up some values
Secrets of the JavaScript Ninja, Second Edition

This is an excerpt from Manning's book Secrets of the JavaScript Ninja, Second Edition.

Figure 1.1. Client-side web applications rely on the infrastructure provided by the browser. We’ll particularly focus on the DOM, events, timers, and browser APIs.
Listing 5.4. Using a closure in a timer interval callback

During this exploration, we’ll put a special focus on timers, a JavaScript feature that enables us to delay the execution of a piece of code asynchronously by a certain amount of time. At first glance, this might not seem like much, but we’ll show you how to use timers to break up long-running tasks that make applications slow and unresponsive into smaller tasks that don’t clog the browser. This helps develop better-performing applications.

You’ve already examined exactly what happens when an event occurs. But timers are different from standard events, so let’s explore an example similar to the ones you’ve seen so far. The following listing shows the code used for this example.

Node.js in Practice

This is an excerpt from Manning's book Node.js in Practice.

2.4. Delaying execution with timers

Node implements the JavaScript timer functions setTimeout, setInterval, clear-Timeout, and clearInterval. These functions are globally available. Although they’re part of JavaScript as defined by Mozilla, they’re not defined in the ECMAScript standard. Instead, timers are part of the HTML DOM Level 0 specification.

Listing 2.20 uses setTimeout to simulate a long-running operation that will keep the program running while the timer displays the process’s memory usage. Once the timeout’s delay has been reached, the program will exit without calling clearTimeout.

Listing 2.20. Keeping a timer alive until the program cleanly exits
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest