not asynchronous function executed as jQuery Deferred

前端 未结 1 805
我寻月下人不归
我寻月下人不归 2021-02-19 22:34

Lets say I want to process some tasks in the synchronous manner, so I have this function:

function executePromiseQueueSync(queue){
    var seed = $.Deferred(),
          


        
相关标签:
1条回答
  • 2021-02-19 23:12

    You dont need to do anything special in order to use sync code as promise.

    Just return value that is ==true

    $.when((function() {
        return prompt('really?')
    })()).then((function() { 
        return alert('yeah') 
    })()).done((function () { 
        alert('done') 
    })())
    
    0 讨论(0)
提交回复
热议问题