JSFiddle - React, Tailwind, and code Playground

by sfoster

HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Dojo (trunk)</title>

    <script type="text/javascript">
        dojo.ready(function(){
            
            var sequenceThese = function(methods, thisObj) {
                // summary: 
                //         Create a sequence of method calls that will execute in order, 
                //         with each being optionally asynchronous
                //         Methods can manipulate the sequence at runtime 
                //         e.g. to unshift or push more functions onto the queue

                thisObj = thisObj || dojo.global;
                var sequence = [].concat(methods);

                sequence.start = sequence.next = function() {
                    var fn = this.shift();
                    if(fn) {
                        if(typeof fn == "string") {
                            fn = thisObj[fn];
                        }
                        var promiseOrValue = fn();
                        return dojo.when( promiseOrValue, dojo.hitch(sequence, function(){
                            return sequence.next();
                        }) );
                    }
                };
                return sequence;
            };

            var seq = sequenceThese([
                function() { console.warn("1st"); },
                function() { 
                    var dfd = new dojo.Deferred();
                    setTimeout(function(){
                        console.warn("2nd, from async response"); 
                        dfd.callback("async response");
                    }, 3000);
                    return dfd;
                },
                function() { console.warn("third"); }
            ]);
            seq.start();
        })
    </script>
</head>
<body class="tundra">

</body>
</html>