Open dunnock opened 7 years ago
Is it just "copy&paste" replacement throughout the code?
No, basically you replace callbacks
sigma.parsers.gexf(
this.props.path ,
this.props.sigma ,
this.onLoad
)
with async/await:
await loadGexf();
but it requires:
function taking callback converted to Promise:
loadGexf() {
return new Promise((resolve) => sigma.parsers.gexf(this.props.path, this.props.sigma, resolve));
}
async function body (in this specific piece of code it is as below, in other placed whenever function instantiating callback is called):
async load() {
const sigma = this.props.sigma;
if(!sigma) return;
await loadGexf();
sigmaI.refresh();
this.setState({loaded:true});
this.props.onGraphLoaded &&
this.props.onGraphLoaded();
}
can be written as: