Building a Countdown Timer With Socket.io Pt. 2
Continuing from yesterday’s post we started out with a rather crude timer and today I want to upgrade it to a full fledged model, Stopwatch
, which dispatches events for the view to hook on to.
Continuing from yesterday’s post we started out with a rather crude timer and today I want to upgrade it to a full fledged model, Stopwatch
, which dispatches events for the view to hook on to.
Yesterday I put together a very simple Node/Socket.io application and showed how to deploy it to Heroku. Today I’m going to keep going with that app to see if I can get the functionality that I want. The app is a basic stopwatch so that shouldn’t be too hard. If you want to catch up checkout yesterday’s article which explains setting everything up.
Update: This page has been translated into Spanish by Maria Ramos.
At my office we like to shoot each other from across the room with Nerf guns. In an effort to actually remain productive we’ve implemented a rule that whenever you get shot you’re dead for 1 hour. But that hour can be a little tricky to keep track of between players. Who’s dead and who isn’t? Am I about to be shot right now??
In an effort to keep track of things (and also because I need to write a blog post) I decided to start working on a little Node.js and Socket.io app. In this first post I’m just going to get things setup and deploy them to Heroku. Hopefully tomorrow we can work on implementing the actual timers. If you’ve never worked with Heroku before you’ll need to follow their getting started guide to make sure you have all the proper command line tools. Don’t worry, it’s really easy and their documentation is awesome.
Last week I did a post on how to load an Underscore template using jQuery’s Deferred method. I got some great feedback from folks and decided I should do a follow up showing how to create your own Deferreds.
Yesterday I wrote a post to illustrate the concepts behind the State pattern (one of my all time favorite tools). If you’re new to this pattern and haven’t read my previous post I suggest you start there and read this one after you’ve had a chance to play around with the ideas.
Last week I wrote a post about communicating between views in Backbone.js and since then it has easily become my most popular article. The comments have forced me to think about the ways in which I typically manage state in very large Flash applications and how that might translate to JavaScript and Backbone. Today I want to present my all time favorite design pattern, the State pattern, and illustrate how it can help you maintain control of your application. I want to warn you that I’m going to show a rather large block of what looks like repetitive code because I want the pattern to be obvious. In tomorrow’s post we’ll clean it up and try it out with a Backbone Model and View.