<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>trickeries! &#187; request.queue</title>
	<atom:link href="http://trickeries.com/tag/requestqueue/feed/" rel="self" type="application/rss+xml" />
	<link>http://trickeries.com</link>
	<description>it's tricky to rock a style thats liked online</description>
	<lastBuildDate>Tue, 02 Mar 2010 06:01:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Queuing ajax requests with MooTools 1.2</title>
		<link>http://trickeries.com/189/queuing-ajax-requests-with-mootools-12/</link>
		<comments>http://trickeries.com/189/queuing-ajax-requests-with-mootools-12/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 05:24:03 +0000</pubDate>
		<dc:creator>atom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[request.queue]]></category>
		<category><![CDATA[toy]]></category>

		<guid isPermaLink="false">http://trickeries.com/?p=189</guid>
		<description><![CDATA[UPDATE: This might be sorta useless.  Please see this comment.
There have been a variety of occasions where I only want one instance of the Request object, but want to make sure that every request I attempt gets run without canceling another, or screwing around with onCompletes.  The following is a rather simple implement that [...]]]></description>
			<content:encoded><![CDATA[<h2><strong title="updated 08/06/2008 4:06 AM">UPDATE</strong>: This might be sorta useless.  Please see <a href="http://trickeries.com/189/queuing-ajax-requests-with-mootools-12/#comment-1825">this comment</a>.</h2>
<p>There have been a variety of occasions where I only want one instance of the Request object, but want to make sure that every request I attempt gets run without canceling another, or screwing around with onCompletes.  The following is a rather simple implement that takes care of this problem:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Request.<span style="color: #0066FF;">implement</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#123;</span>
    queue<span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span>sendArg<span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
        <span style="color: #00FF00; font-weight: bold;">if</span><span style="color: #99FF00;">&#40;</span><span style="color: #339933;">!</span>$defined<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">queued</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span>
            <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">queued</span> <span style="color: #339933;">=</span> <span style="color: #99FF00;">&#91;</span><span style="color: #99FF00;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">queued</span>.<span style="color: #0066FF;">push</span><span style="color: #99FF00;">&#40;</span>sendArg<span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">processQueue</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #99FF00;">&#125;</span><span style="color: #339933;">,</span>
    processQueue<span style="color: #339933;">:</span> <span style="color: #FF00FF; font-weight: bold;">function</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#123;</span>
		<span style="color: #00FF00; font-weight: bold;">if</span><span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">timer</span><span style="color: #99FF00;">&#41;</span>
			$clear<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">timer</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">if</span> <span style="color: #99FF00;">&#40;</span><span style="color: #339933;">!</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">check</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span>
			<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">timer</span> <span style="color: #339933;">=</span> <span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">processQueue</span>.<span style="color: #0066FF;">delay</span><span style="color: #99FF00;">&#40;</span><span style="color: #FFFF00;">250</span><span style="color: #339933;">,</span> <span style="color: #00FF00; font-weight: bold;">this</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #00FF00; font-weight: bold;">else</span> <span style="color: #99FF00;">&#123;</span>
			<span style="color: #00FF00; font-weight: bold;">if</span> <span style="color: #99FF00;">&#40;</span>$defined<span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">queued</span><span style="color: #99FF00;">&#91;</span><span style="color: #FFFF00;">0</span><span style="color: #99FF00;">&#93;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span> <span style="color: #99FF00;">&#123;</span>
				<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">send</span><span style="color: #99FF00;">&#40;</span><span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">queued</span>.<span style="color: #0066FF;">shift</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">processQueue</span><span style="color: #99FF00;">&#40;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #99FF00;">&#125;</span>
			<span style="color: #00FF00; font-weight: bold;">else</span>
				<span style="color: #00FF00; font-weight: bold;">this</span>.<span style="color: #0066FF;">fireEvent</span><span style="color: #99FF00;">&#40;</span><span style="color: #3366CC;">'onQueueEmpty'</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #99FF00;">&#125;</span>
    <span style="color: #99FF00;">&#125;</span>
<span style="color: #99FF00;">&#125;</span><span style="color: #99FF00;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will basically stack requests and send them in the order received.  If there is no stack, the request will be sent immediately.</p>
<p>The usage is the same as the normal <a title="MooTools request send method" href="http://docs.mootools.net/Request/Request#Request:send">Request send method</a>, however there is now an onQueueEmpty event to tell when all requests in the queue have been sent.</p>
<h2><a title="Request.queue() example usage / demonstration" href="http://trickeries.com/demo/Request.queue/">example</a></h2>
<h2><a title="Download the example for Request.queue()" href="http://trickeries.com/wp-content/uploads/2008/07/requestqueue.zip">download w/the example</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://trickeries.com/189/queuing-ajax-requests-with-mootools-12/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
