Hi,
Whether async function calls are supported while listening for events before the drag。
Take a look at the following example
function getSomething() {
var r = 0;
return new Promise(function(resolve) {
setTimeout(function(){
r = 2;
resolve(r);
},10)
})
}
gantt.attachEvent(“onBeforeTaskDrag”, async function (id, mode, e) {
const res = await getSomething()
if(res === 2){
return true
} else {
return false
}
}, null);
Hello,
You can start the async action from the event handler, but the gantt won’t stop processing to wait until the async action is completed. So, in your case, when you will move the task it won’t be able to move until the variable res
would change.
How to start the async action from the event handler?
How to stop the gantt processing to wait until the async action is completed
@Alexsander_Silva
Thank you
How to start the async action from the event handler?
How to stop the gantt processing to wait until the async action is completed?
Can you give me a example?
Hello,
Currently, onBeforeTaskDrag
method doesn’t support asynchronous operations. The dev team will add that feature in the future, but I cannot give you any ETA.
For now, you need to call the getSomething()
function before the onBeforeTaskDrag
event handler.