Design pattern to support last-in callbacks (e.g. handling hashchange)
<p>On my web page, I have multiple independent plug-ins (for lack of a better word) that all interact with the <code>location.hash</code> of the browser. (I have a bit of code that keeps their work separated, but that's irrelevant to this question.) For example, I have:</p>

<pre><code>// file1.js
$(window).bind('hashchange', function(){ ... } );

// file2.js
$(window).bind('hashchange', function(){ ... } );
</code></pre>

<p>The above works as desired when the hash changes after the page loads. However, I also need this code to process whatever hash the page initially loads with. If I write this code:</p>

<pre><code>// file1.js
$(window).bind('hashchange', function(){ ... } ).trigger('hashchange');

// file2.js
$(window).bind('hashchange', function(){ ... } ).trigger('hashchange');
</code></pre>

<p>...then the first set of code will be run twice. Not desirable.</p>

<p>What's a good pattern for triggering the <code>hashchange</code> event only once, after all event handlers have been put in place?</p>
