JSFiddle - React, Tailwind, and code Playground

by yeuem1vannam

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/q.js/1.1.2/q.min.js"></script>

CoffeeScript

async_func = ->
    d = Q.defer()
    # Do something async
    console.log("M: Should I?")
    setTimeout((->
        console.log("M: OK, give him")
        d.resolve("M: Here're all mine")
    ), 10000)
    console.log("M: Ahhh, wait for my thinking")
    d.promise

main_func = ->
    console.log("T: Free hand! Give me your money!")
    console.log("T: You have 10 secs to think...")
    async_func().then((async_promise)->
        console.log(async_promise)
    ).done((->
        console.log("T: OK, you're dead! BAM")
    ))
    console.log("Hmmm?")
    setTimeout((->
        console.log("T: My gun is waiting")
    ), 5000)

main_func()