Asynchronous Grunt Tasks

Update: Thanks to @waynemoir for updating the example source to work with Grunt ~0.4.

After my last post @stevensacks tweeted at me that he was having issues getting node FileSystem commands to work in grunt. After a bit of poking around I noticed that there was no call to grunt’s async method, which was probably preventing the process from finishing properly. So today’s post is a primer on async grunt processes, and how to make sure your node and grunt syntax is setup correctly.

A Require.js Multi-page Shimmed Site: How-To

I’ve been working with RequireJS a lot lately and found it really improves the way I manage my code. I had previous experience with Require in the context of some of my Backbone posts, but I’d never used it on a more traditional multi-page site before. The process of setting up Require on a multi-page site can be pretty confusing, so I thought I would put together this tutorial to help out others who might be stuck.

Virtual Host in Mountain Lion With Apache

If you’re using Mountain Lion and have the need to setup a vhost it can be a little tricky to get the ball rolling. I’m going to do my best to detail the process that I use to set everything up. Hopefully you can use these same steps to square aware your system.

JavaScript Design Patterns: Factory

Table of Contents

Factories encapsulate and separate object creation from the rest of your code. In situations where the creation of an object can be complex or subject to change a factory can act as a nice buffer to help keep things tidy. Without proper planning Factories can lead to class explosions; as a result the pattern can be both a blessing and a curse depending on how it’s used.

JavaScript Design Patterns: Decorator Update

Yesterday’s post drew a lot of traffic from Reddit and with it came some really good feedback. If you haven’t read the previous post please do so first and then come back here.

I want to go through some of what was said so I can refine my examples and also clear up any confusion.

JavaScript Design Patterns: Decorator

Table of Contents

Update: Part 2 has been posted!

A Decorator is an object which adds functionality to another object dynamically. It can be used to enhance the behavior of an object without requiring the author to reopen its class. While Decorators might feel a little weird to implement in static languages they’re extremely simple in JavaScript due to the ease with which JS passes around functions and handles dynamic types.