Javascript callback function and an argument in the callback. How must it be used based on the code snippet provided? -
i'm reading on legacy codebase , ran following code:
andthenwe: function(callback) { var qunitassertasync = new window.assertasync(callback); return qunitassertasync; },
and here's call site:
andthenwe(function(done) { ...(some code) done(); });
so in call site, we're passing in anonymous function === 'callback' right? however, callback has argument called done , seems called @ end of function. argument kind of block parameter in ruby right? somewhere in window.assertasync
callback must called , passed kind of arugment === qunit's assert.async
right? (most likely). details of window.assertasync
complicated want understand @ high level must going on. making proper assumptions?
this possible because callback
in function signature anonymous function invoked @ later time right? done
in callback function must function @ runtime right?
i think attempt make qunit.async
more "readable" (haha).
qunit.async
used force tests wait until async operation has completed before exiting test.
the done
callback must invoked when writer of test knows async has completed.
Comments
Post a Comment