Back to all projects

pomodoro-web

A Pomodoro timer I wrote in Angular and TypeScript while learning the framework. Pick 25, 15 or 5 minutes, or type your own, and it beeps until you stop it.

Overview

This is a simple timer for working in short, focused blocks. It shows a countdown, a Start button and a Stop button, three presets for 25, 15 and 5 minutes, and a box for any number of minutes you like. When time runs out it beeps every second or so until you press Stop.

I built it while learning Angular, and I don’t maintain it.

The timer showing 25:00, with Start and Stop buttons, three preset buttons and a box for entering the time in minutes.

How the timer keeps time

The obvious way to write a countdown is to subtract one second each time a timer fires. The trouble is that browsers don’t promise to fire a timer exactly on schedule. They can delay it, particularly in a background tab, and the countdown slowly drifts.

So this timer doesn’t count ticks. It remembers when it started, and each time it checks, it works out how much time has really passed and subtracts that from the full duration. A late tick only means the display updates a little late. The number it shows is still correct.

How it’s organized

The app is split into Angular components for the timer, its display, the buttons and the input box. A TimerService holds the logic, and a separate Timer class keeps the state of one timer. The code has documentation comments throughout, and the repository includes a generated documentation site, made with Compodoc, that describes every component and service.