blob: 7c7d6b071d96fd42ae42ceda734027a99f7496a0 [file] [log] [blame]
<body bgcolor="#ffffff">
<H2>Manually wrapped callback function in JavaScript</H2>
This example demonstrates how to manually add callback feature support to a SWIG module.
<li><a href="example.i">example.i</a>. Interface file containing the API function and async behind-the-scenes functions.
<li><a href="">runme.js</a>. Sample JavaScript program showing the API function being called with a callback function parameter.
The V8 code queues the callback request for processing using the UV interface. An async function callback is invoked when the system is ready to process the next request. When the async function finishes, a completion function callback is invoked to finalize the request. Here the callback function parameter is invoked.
UV request queueing is only necessary for operations that would take a really long or otherwise unpredictable amount of time (async operations). A callback parameter could also be invoked immediately within the API function.