Creating a Digital Clock

The following image shows the clock running in a browser. All the irrelevant details of the browser window, such as the menus, toolbars, and scrollbars, are not shown so that we can concentrate on the code.

images/clock1.png

The essential part of this application is the display. This contains a time, which is updated every second. From the Erlang point of view, the entire browser is a process; so, to update the clock to the value shown earlier, Erlang sent the browser the following message:

 
Browser ! #{ cmd => fill_div, id => clock, txt => <<​"16:30:52"​>> }

Inside the browser, we have loaded an HTML page with a small fragment of HTML ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.