Questions tagged [asynccallback]

A callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. An asynchronous or deferred callback is invoked after a function returns, or at least on another thread’s stack.

A callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. An asynchronous or deferred callback is invoked after a function returns, or at least on another thread’s stack.

More Info

457 questions
140
votes
10 answers

nodeJs callbacks simple example

can any one give me a a simple example of nodeJs callbacks, I have already searched for the same on many websites but not able to understand it properly, Please give me a simple example. getDbFiles(store, function(files){ getCdnFiles(store,…
Bhushan Goel
  • 2,114
  • 3
  • 19
  • 31
33
votes
5 answers

invoke aws lambda from another lambda asynchronously

I need to invoke aws lambda from another lambda asynchronously. i have a working code for synchronous calls. exports.handler = (event, context, callback) => { var aws = require('aws-sdk'); var lambda = new aws.Lambda({ region:…
30
votes
4 answers

JavaScript doesn't seem to wait for return values

I've been struggling with this for a while now. I'm new to Javascript, and have been under the impression that the code I've been writing has been running asynchronously. Here is a generic example: I run some code in function a. Function A then…
Georges Krinker
  • 2,259
  • 4
  • 25
  • 24
22
votes
4 answers

Is Javascript synchronous(blocking) or Asynchronous(nonblocking) by default

I am trying to grasp on Javascript Asynchronous functions and callbacks. I got stuck on the concept of callback functions, where I am reading on some places: they are use to have sequential execution of code (mostly in context of jquery e.g…
21
votes
3 answers

For-loop and async callback in node.js?

I'm new to JavaScript and to node.js. I want to loop through a directory and add all file stat (not other directories) to an array. As you see below there is a problem with my code since the callback will probably get called after the for loop has…
exkoria
  • 1,176
  • 2
  • 13
  • 27
17
votes
1 answer

in express how multiple callback works in app.get

I am newbie in node so please forgive me if i am not getting obvious. In node.js express application for app.get function we typically pass route and view as parameters e.g. app.get('/users', user.list); but in passport-google example I found…
Tushar Jambhekar
  • 181
  • 1
  • 1
  • 3
15
votes
3 answers

nodejs Async's whilst

Greeting all, I want to call a function repeatedly, but wanted each call to run only when the previous call is completed. Does the Async's whilst fit what I need? Or do the calls happen in parallel? Thanks! Gary
Gary
  • 483
  • 2
  • 6
  • 17
14
votes
1 answer

Javascript function returning undefined value in nodejs

I am writing code for getting data. First I call **getsomedata** function to get data and inside getsomedata function I am calling another function getRandomdata to get data and returning it back to the previous function but it is returning…
iam
  • 973
  • 4
  • 11
  • 21
13
votes
4 answers

Pass argument to AsyncCallback function?

I'm learning socket programming and I have the following function: public void OnDataReceived(IAsyncResult asyn) and this is how the callback gets set: pfnWorkerCallBack = new AsyncCallback(OnDataReceived); The problem is I need to pass another…
user1192403
  • 597
  • 2
  • 5
  • 19
11
votes
3 answers

Run a function when a Task finishes

I have want to run a function asynchronously to prevent UI freezing. Here the the button click event. private void btnEncrypt_Click(object sender, EventArgs e) { // Create new Vigenere object instant cryptor = new Vigenere(txtPassword.Text,…
Xbyte Finance
  • 173
  • 1
  • 1
  • 9
11
votes
3 answers

$(document).ready inside $(document).ready

I found code in my codebase that has $(document).ready(function() {...} inside of another $(document).ready(function() {...} e.g. $(document).ready(function() { // 20 lines... $(document).ready(function() { foo() } …
David Groomes
  • 2,303
  • 1
  • 21
  • 23
9
votes
1 answer

google charts - run function after draw

working with google charts, trying to get a value from the chart after it is done drawing, I understand I need to make a callback function that will run after 'draw' is complete - but I can't get it to work... Where do I call the function…
Haksuma
  • 103
  • 1
  • 5
9
votes
2 answers

How to implement reusable callback functions

I am fairly new to JavaScript and I am working in node which requires a good understanding of async programming and callback design. I have found that using embedded functions is very easy to do even when your callbacks are multiple levels deep. …
rss181919
  • 427
  • 1
  • 5
  • 16
8
votes
2 answers

Mocking a Vertx.io async handler

when I was sync I wrote unit tests mocking the persistence part and check the caller's behavior. Here is an example about what I usually did: @Mock private OfferPersistenceServiceImpl persistenceService; @Inject @InjectMocks private OfferServiceImpl…
Francesco
  • 1,742
  • 5
  • 44
  • 78
8
votes
3 answers

Retrofit 2 enqueue method running 2 times

I am new to Retrofit Library. I am working on an app in which I've to make multiple API calls, but this problem sticks me when I tried to make my first API Call... I am facing the issue that whenever I used to call retrofit's Asynchronous call…
Saumya Rastogi
  • 13,159
  • 5
  • 42
  • 45
1
2 3
30 31