I am using JavaScript, and I have an event hook for drag & drop. If I return
false
, the drop action will be aborted. Within that event hook I need to call an ASYNC function
(to lookup an entity) as part of my decision making.
Hooks.on("dragdrop", (context, data) => {
const pack = context.pack.get(data.packId); //ok, this is synchronous
const item = pack.getEntity(data.id); // BAD: async returns promise, not item
if (item.type === "blah") { // this fails, since I got a promise
return false; // rejects dragdrop action
}
return true;
});
I must have this hook (callback) return an appropriate value (true/false), but if I use a the ASYNC function
getEntity()
I won't get a value back, just a promise that will eventually return the item. How do I solve this problem?