callback

JQuery call function when all AJAX requests are complete

可紊 提交于 2020-01-01 07:02:33
问题 My question is a variant of the question here However, there are two differences: I don't know how many AJAX requests there are. For sure, there are at least 10. They run concurrently, or almost concurrently, and the number of requests changes every time. The function that I want to call makes AJAX requests as well. I don't want the AJAX requests to go on forever (which is what happened when I first tried). I only want this functionality one time. Here is my code: $("#calculateButton")

Design Pattern - Callback [closed]

这一生的挚爱 提交于 2020-01-01 06:53:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I have to do a presentation of the callback pattern. I just want to be sure that I got it right because of what I read about callbacks, callback functions and callback pattern... The design pattern callback is very similar to the observer pattern. The first one is easier to

Invoking Actions from Moq

北城余情 提交于 2020-01-01 06:43:13
问题 I've got a service with a method that takes two Action s, one for success and one for failure. Each Action takes a Result parameter that contains additional information... void AuthoriseUser(AuthDetails loginDetails, Action<AuthResult> onSuccess, Action<AuthResult> onFailure); I'm writing a unit test for a class that is dependant on that service, and I want to test that this class does the correct things in the onSuccess(...) and onFailure(...) callbacks. These are either private or anonymous

Node.js: How to properly return an object from within a callback?

送分小仙女□ 提交于 2020-01-01 06:11:25
问题 Still wrapping my head around callbacks. What's the proper way to define/return an object from within a callback function? You can see my 2 console.logs in the following snippet, the one outside of the callback is of course undefined, how do I define it? In my app.js: var tools = require('../models/tools.js'); app.get('/games', requireAuth, function (req, res) { var gameqlist = tools.getMyGameQs(req, function(err, gameqlist){ console.log(gameqlist); // this is properly defined return

Node.js: How to properly return an object from within a callback?

谁说我不能喝 提交于 2020-01-01 06:11:12
问题 Still wrapping my head around callbacks. What's the proper way to define/return an object from within a callback function? You can see my 2 console.logs in the following snippet, the one outside of the callback is of course undefined, how do I define it? In my app.js: var tools = require('../models/tools.js'); app.get('/games', requireAuth, function (req, res) { var gameqlist = tools.getMyGameQs(req, function(err, gameqlist){ console.log(gameqlist); // this is properly defined return

How to use a WCF Dual Service over the internet?

跟風遠走 提交于 2020-01-01 05:38:08
问题 I followed this tutorial (at least based my WCF in this, coz I need then to work alike): http://www.eggheadcafe.com/tutorials/wcf/b5ada8df-58c5-492f-b368-457b3a4f137c/notify-client-applications-using-wcf-callbacks.aspx It's working very well on my computer, but i need to use it over the internet. While trying to do this I heard (over the internet) that is better to use netTcpBiding. I gonna have a server that is going to be aware of the number of clients online. I wanted a WFC service on my

ActiveRecord Global Callbacks for all Models

邮差的信 提交于 2020-01-01 05:35:44
问题 I have around 40 models in my RoR application. I want to setup a after_save callback for all models. One way is to add it to all models. Since this callback has the same code to run, is there a way to define it globally once so that it gets invoked for all models. I tried this with no luck: class ActiveRecord::Base after_save :do_something def do_something # .... end end Same code works if I do it in individual models. Thanks, Imran 回答1: You should use observers for this: class AuditObserver

Can I use a lambda function or std::function object in place of a function pointer?

☆樱花仙子☆ 提交于 2020-01-01 04:26:05
问题 I've got a library that I need to use that defines the following: typedef void CallbackFunction(const int& i); and has a function to register your callback that looks like: void registerCallback(CallbackFunction* pCallback); Because I'd like to capture the state of several variables to be used in the callback, I can't simply use a plain function. What I'd prefer to use is a lambda function, but the following doesn't compile: auto fCallback = [](const int& i) { cout << i << endl; };

Are anonymous listeners incompatible with weak references?

天涯浪子 提交于 2020-01-01 02:08:33
问题 I was reading this question that just got asked: Avoid memory leaks in callbacks? And I was quite confused, until someone answered the following: "The problem with this approach is you cannot have a listener which is only referenced in the collection as it will disappear randomly (on the next GC)" Am I correct in my understanding that using a weak references, like when stored in a WeakHashMap , is incompatible with anonymous listeners? I typically pass listeners like this: public static void

aws lambda execution after callback guaranteed?

亡梦爱人 提交于 2020-01-01 01:56:21
问题 My node4 lambda function called via API GW makes a sequence of slow API calls. In order to not let users wait until everything completes, I'm planning to have my code look like this: function(event, context, callback) { ... // Return users API GW call now callback(null, data); // Do the heavy lifting afterwards. longApiCall().then(otherLongApiCalls) } But now I read in the AWS docs: "the callback will wait until the Node.js runtime event loop is empty before freezing the process and returning