Closed
Description
It would be a nice funcionallity to be able to return promises in the clientside callbacks.
Right now it is impossible to make web requests in the clientside.
This would help to take some load from the server side, which would greatly improve the dash apps performance
Example of what I mean:
async function MakeWebRequest(type) {
var _url = "https://test.api.com/entities/?type="+type
var headers = {
"Accept":"application/json"
}
var config = {
url: _url,
headers: headers,
method: 'get'
}
return await axios(config)
.then(data => {
return data
})
.catch(error => {
console.log(error);
return error;
});
}
async function updateDropdown(name, path, previous_value) {
var disabled = false
...
if (courseID !== '') {
var options = await MakeWebRequest("course");
return [disabled,courseID, options]
}
}
window.dash_clientside = Object.assign({}, window.dash_clientside, {
newQuestionnaire: {
updateDropdown: async function (name, path, previous_value) {
return await updateDropdown(name, path, previous_value);
}
}
This raises this type of error in the Web Page:
I think this should be a feature to really consider in future releases.
I really like how dash lets you abstract from javascript, But it is still lacking the the ability to offload demanding jobs to the clientside...