wait for a callback to end without nesting

Viewed 24

i'm working with fabricJS and it's callback based library to parse canvas <--> svg and i'm stuck in the following senario.

function A () {
   ...
   B(svgString)
   ...
}

function B (svgString) {
   ...
   fabric.loadSVGFromString(svgString, function(objects, options){
      ...
      canvas.add(..);
      canvas.renderAll();
   });
   ...
}

When using this with a simple svg file it workes fine, but when loading an svg with an embedded base64 png it jumps to the next instruction in function A without completing the callback in function B

0 Answers
Related