Tuesday, February 7, 2017

Status of the Callbacks

somefunction( parameter, function(response) {
    response
    // do something after the response  function(response)
});

Get error:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function

--------------------------------------------------------------------------------------------------
function longProcess(url, fn) {
  createprimatives(url, function(dummy) {
      fn(dummy);
  });
};

longProcess(url, function(graph) {
  var width = 800;
  var height = 800;
  console.log(graph); /// this takes awhile
});

longProcess(url, function(graph) {
  var width = 800;
  var height = 800;
  draw(width,height,graph); // this fails
  console.log(graph); /// this takes awhile
});


longProcess(url, function(graph) {
  var width = 800;
  var height = 800;
  var graph = someObject;
  draw(width,height,graph); // this succeeds
  console.log(graph);
});

No comments:

Post a Comment