FAQ Database Discussion Community


call functions in async with node which is more recomended Q or callback

javascript,node.js,callback,promise,q
I've node app with function that inside call to to other two function,I want to use some async behavior for it,what is recommended to use in this case. example will be very helpful. function myFunction(req,res){ //from here this is the first place which I want to use warp in function...

Chrome identity launchWebAuthFlow only opens empty callback page

javascript,google-chrome-extension,callback,oauth-2.0,identity
Sorry for yet another probably noob question, normally I don't give in until I find a solution myself but this one has me going for 3 days and it is time to admit I'm stuck... I'm trying to authenicate a Chrome extension to use PushBullet user data via OAuth2: background.js...

Is it possible to call a function after typing each keyword in ace-editor

callback,keyword,ace-editor
What I want to do is that in ace-editor, each time when I finished typing a keyword, a function can be called automatically. For example, I TYPE the keyword "new" in ace-editor. After I finished typing, an alert function will be called and say "you have typed the keyword 'new'"....

NODE/EXPRESS/PASSPORT - Facebook App with Callback URL

node.js,facebook,express,callback
I am creating a facebook app. And I want to let users to login to my website using FB. I have integrated the code but FB cannot found the callback page/url. URL: http://www.mywebsite.com:3000/auth/facebook/callback?code={here_goes_the_callback_code} Error: The webpage cannot be found app.js var express = require('express'); var routes = require('./routes'); var http...

Nested javascript callback functions

javascript,callback
Can someone explain why this works (i.e. delay 1 executes before delay 2): function testCallBack() { one(two); } function one(callback) { setTimeout(function () { alert("delay 1"); callback(); }, 2000); } function two() { setTimeout(function () { alert("delay 2") }, 1000); } testCallBack(); http://jsfiddle.net/z71gkpfg/ but this doesn't (delay 2 somehow executes...

passing callback or promise to the different module , which one is better and efficient?

callback,promise,loopbackjs
In my application, I am passing callback to different module and so on. Same thing I am able to achieve using bluebird promise. According to best code practice, which one is better?...

Why navigation controller does not navigate in callback using Swift?

swift,callback,navigation,navigationcontroller
I have created a navigation controller and assigned it to my View Controller in Swift. I created the following method: @IBAction func btnLoginPressed(sender: AnyObject) { let userManager = UserManager() userManager.login(txtBoxLogin.text, password: txtBoxPassword.text, operationCompleteHandler: { (token: String?) -> Void in if let token = token { ApplicationState.ApiToken = token var mainView...

calling internal method for each object in an array

javascript,arrays,foreach,callback
I have a "class" with properties and methods. And I have instances of that class in an array in some other place in the code. Now I want to iterate through all of them and for each call a method. Something like this: arr.forEach(draw()); But of course it looks up...

How to evenly time fading transitions?

javascript,jquery,callback,setinterval,fade
so I'm trying to create a simple slide show from scratch, and so far I was able to get full screen images to fade out and fade in infinetly, but for some odd reason using setInterval(function(){fade(var)}, 3500);didn't work, maybe someone can explain why the first and last images took way...

Should I and how to transitionToRoute in a promise callback

javascript,ember.js,callback,promise,ic-ajax
In an Ember controller, I want to call my API to create a user and on success, transitionToRoute. This is what I currently want to work: import ajax from "ic-ajax"; import Ember from "ember"; export default Ember.Controller.extend({ actions: { createAndLoginUser: function() { var user = { "user": this.getProperties("email", "name") };...

C# language doesn't need the concept of delegates? [closed]

java,c#,c++,callback,delegates
Thanks for your objectivity, especially where C# is your language of choice. Angry downvoters, I think I've asked a legitimate question here? Otherwise leave a constructive comment, please. To the question... C++ allows passing of (generic) function pointers simply, as follows: How to pass a generic function pointer as parameter...

Twilio: Best method for retrieving media uri for sent sms

callback,sms,twilio
When my server sends an SMS with the MediaUrl parameter specified, I want to utilize the link location(s) that Twilio assigns to the image(s) to construct img tags with src properties based on media->uri. Up until today, the following code was working... $client = new Services_Twilio($twilio_sid, $twilio_token); $params = array...

MeteorJS: Callback after template helper was updated

javascript,templates,meteor,callback,helper
I'm new to Meteor.js, so hopefully this is an inability on my part rather than a limitation of the platform because it's pretty amazing otherwise. What I'm trying to achieve is pretty straightforward: run Javascript whenever a template helper gets updated with new data (but not from the db!). A...

C++ Java Handler equivilent

c++,callback,delegates
I'm coming from a Java/C# background and am new to C++. I am writing a library and am trying to accomplish the same functionality as a Handler does in Java. My scenario is as follows: I am building a WinRT library that a user will put into his mobile/desktop app....

Calling helper function in node.js within callback?

javascript,node.js,asynchronous,express,callback
I'm fairly new to programming with node.js and am not quite sure why I am getting this error. The function looks to be set up correctly, and I don't believe I have any asynchronous problems b/c those should be account with the self variable I put in place (I think)....

after_touch callback does not have access to updated attributes of children

ruby-on-rails,callback
I am not sure how to resole the following egg-and-chicken problem. I have model called Batch that touches parent model Status on validation - via before_validation callback. In after_touch callback in parent model - Status, (status has_many batches) - I am checking if all children of Status instance are having...

Using Mongoose.js Model.Remove(conditions, callback) - remove successful but callback not being called

node.js,mongodb,callback,mongoose
I've simplified down to the following most basic possible version... UserModel.remove({ }, function (err) { console.log("inside callback"); }) I've verified that the records are being removed but the callback is never called. I've successfully added documents using var user = new UserModel(req.body); user.save(function (err) { if (err) { return (next(err));...

Twitter4J Creating Callback URL That Goes Back To My App

java,android,twitter,callback,twitter4j
I've read through this: Android: Login with Twitter using Twitter4J And the selected answer doesn't make sense in the context that I need it. I want the user to be able to login to their Twitter account from our app, and then, once they've logged in, I want our app...

Using RAII for callback registration in c++

c++,c++11,callback,synchronization,raii
I'm using some API to get a notification. Something like: NOTIF_HANDLE register_for_notif(CALLBACK func, void* context_for_callback); void unregister_for_notif(NOTIF_HANDLE notif_to_delete); I want to wrap it in some decent RAII class that will set an event upon receiving the notification. My problem is how to synchronize it. I wrote something like this: class...

Fragment callbacks explosion, how to deal?

android,design-patterns,android-fragments,android-activity,callback
I am creating my app with using fragments. I have something like main activity, it has FrameLayout as root layout to hold fragments. After much thought I have decided to separate my application logic in several parts, for example : MainActivity is responsible for app basic navigation (MainPageFragment, CategoryListFragment, ProductListFragment,...

How can I ensure synchronous execution without nesting callbacks?

javascript,asynchronous,callback
I have this JavaScript code that iterates through an indexedDB object store and returns all of the objects it contains. I need to wait until the method is finished before I continue on with my code because I need to make use of the array variable that the code will...

C# Garbage Collector Begin/End Callback [duplicate]

c#,callback,garbage-collection
This question already has an answer here: Is there an event for when garbage collection occurs in .NET? 5 answers I was just wondering if there is an overridable callback for the garbage collector begin/end in the .NET runtime/C#. I will also state that I have no intentions of...

Selectize.js load callback pass-through to custom function

javascript,jquery,asynchronous,callback,selectize.js
I have configured selectize.js to gather configuration options from html data attributes. One of my configuration types is the ability to specify a js function to call for custom data loading (outside simple ajax loading). The code is working well, until I run a custom function that is asynchronous. With...

Opencv draw a rectangle in a picture were never shown

python-3.x,callback,mouse,opencv3.0,drawrectangle
Hey everybody i have some trouble using opencv 3.x and python 3.x. What i want to do is to draw a basic rectangle in a picture but the rectangle will never be drawn. I read this similar thread but it doesn't helped me with my fault. Python OpenCV: mouse callback...

Backbone's success callback called before jquery's ajaxSuccess

jquery,ajax,backbone.js,callback
I would like to make sure that jQuery's ajaxSuccess callback is called before Backbone's success, which is not the case in my experience. I would like this someModel.fetch({ success: function() { console.log('2'); } }); $(document).ajaxSuccess(function(event, xhr, ajaxOptions) { console.log('1'); }); to log 1, 2 and not 2, 1. The reason...

I'm trying to make the “merge function” work by writing a Callback.

javascript,function,callback,add,indices
I think my understanding of callbacks is pretty green. But this is what have so far and my function is only adding the first index in each array together. var merge = function(array1, array2, callback){ for (var i = 0; i < array1.length; i++) { return array1[i] + array2[i]; };...

Deploy to heroku without redirecting to localhost with passport callback

facebook,heroku,oauth,callback,passport-facebook
I've deployed an app to Heroku, however once you click 'log in with facebook', you are redirected to http://localhost:3000/#=. I've tried the following (the first is where it is at the moment): passport.use(new FacebookStrategy({ clientID: FACEBOOK_APP_ID, clientSecret: FACEBOOK_APP_SECRET, callbackURL: "http://localhost:3000/auth/facebook/callback" }, function(accessToken, refreshToken, profile, done) { process.nextTick(function () { return...

Passing 'this' object to the 'then' callback function of $http service

javascript,angularjs,callback
I am having problems passing 'this' object to the 'then' callback function of $http service as shown below var Product = function(){ this.name = "putty"; this.price = 760; $http.post(url, data).then.call(this, function(){ this.saved = true; }); }; When I inspect 'this' object in the statement this.saved = true, I realise that...

how to build a chain of calls render itemViews in marrionete.js deferred with async function inside itemView

javascript,jquery,callback,marionette,deferred
I have a very simple structure ProductsList.TileListView = Marionette.CollectionView.extend({ tagName: 'section', className: 'b-list-viewtile', template: '/static/js/app/list/modules/productslist/templates/tileList', childView: ProductsList.TileItemView }); ProductsList.TileItemView = Marionette.ItemView.extend({ tagName: "article", className: "b-list-viewtile__item", template: '/static/js/app/list/modules/productslist/templates/tileItem', _getImage: function(){ var _this = this; var img = new Image(); img.src =...

Passing function name as callback doesn't work as expected in my class

php,function,class,callback
This seems straightforward, but the below code is giving the following error. Any suggestions? usort() expects parameter 2 to be a valid callback, function 'cmp' not found or invalid function name My code: function cmp($item1, $item2) { return strcmp(strtolower($item1->last_name), strtolower($item2->last_name)); } public function get_people() { usort($this->my_array, 'cmp'); } ...

Double issue with “this” scope in xmlhttprequest javascript

javascript,ajax,asynchronous,callback,xmlhttprequest
I have two huge issues with this scope in my javascript code. After creating setAJAXGet object, callback function was lost and couldn't be called correctly. So instead of calling this.funct I set ajax.parent = this; and call this.parent.funct - works ok. function setAJAXGet() { this.askServer = function() { var ajax...

AngularJS how to update view/scope after event listener

javascript,angularjs,cordova,callback,listener
I have on my controller and service like this (both on separate file): .controller('authCtrl',['$scope','MyConnect',function($scope,MyConnect){ /***************Testing Area******************/ console.log("connecting"); MyConnect.initialize(); $scope.myID = ??? //I want this to be updated } .factory('MyConnect', ['$q', function($q) { var miconnect = { initialize: function() { this.bindEvents(); }, bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function()...

AJAX callbacks when getting multiple XML files

javascript,ajax,xml,callback
I'm trying to get a better understanding of how callbacks work. In this example, I want to get two or more XML files using AJAX, then extract the content I need from them, and then store that data in an array outside of the AJAX call. I want to use...

Using callbacks instead of promises in AngularJS results in different behavior in unit tests. Why?

angularjs,callback,scope,synchronization,promise
I'm testing a $resource. If I have code like this: $resource.do(stuff).$promise.then(function(data){ console.log(1); }); console.log(2); I get the print out: 2 1 But if I have code like this: var callback = function(data){ console.log(1); } $resource.do(stuff,callback); console.log(2); I get the print out: 1 2 Why? I have found that with the...

npm's guidelines on callback errors

javascript,asynchronous,error-handling,callback,npm
I was reading through npm’s coding style guidelines and came across the following very cryptic suggestion: Be very careful never to ever ever throw anything. It’s worse than useless. Just send the error message back as the first argument to the callback. What exactly do they mean and how does...

R Shiny - filter two table and heatmap simultaneously (with cells of fix width)

r,callback,filtering,shiny
I have two input tables: label and main_plot. I am able to filter the plot using controls in the sidePanel. Column in "main_plot" corresponds to columns of "label". I want to filter both tables using controls simultaneously. (e.g.: if I see only first and second column of "label" after filtering...

jQuery function callback does not work in custom class/object

javascript,jquery,class,object,callback
So am a newbie to programming so excuse me if this is a novice question. I am creating a simple wave effect to create an illusion of moving water. I did this with a simple function in jquery and it worked fine. I am learning OOP so my code is...

Reading pusher data

javascript,arrays,callback,pusher
Can someone help me with the reading of the returned pusher message in the example callback. I've taken this example straight from their website, but the alert box just says 'undefined', however the console.log outputs everything fine. I'm sending test messages via their API console in the account control panel....

Jquery Ajax callback doesn't recognize $(this) object [duplicate]

javascript,jquery,ajax,callback,this
This question already has an answer here: Passing $(this) to a callback in jQuery? 3 answers It it my code $(".library-fields-container div.field-content img").click(function(){ var nid = getImageNodeID($(this).siblings(".image-span").text()); $.ajax({ url: Drupal.settings.basePath + 'views/ajax', type: 'POST', dataType: 'json', data: 'view_name=fehrest&view_display_id=block_1&view_args='+nid, success: function(response) { var output = response[1].data; alert(output); $(this).hide(); }, error:...

Is it possible to convert a Swift class into C void* pointer?

objective-c,c,swift,callback
Is it possible to convert a Swift class into C void* pointer? // swift class class MyClass { } var myClass = MyClass() var p: UnsafeMutablePointer<Void> = myClass //<- failed //c function void someSwiftClass(void *context); Thanks...

waiting in the main code while asynchronous call for get method executes

c#,asynchronous,callback,get
void main() { OpenWeatherApiClient.getCurrentLocationWeatherAsync(55.513434, -37.53434, (x) => { Console.WriteLine(x.coord.lat); Console.ReadLine(); }); } Console.WriteLine("this should happen before"); /// I want to hold the the function here till the call back returns and executes the above logic /// the asynchronous function public static void getCurrentLocationWeatherAsync(double latitude, double longitude, Action<WeatherData> callback) { //weather...

C++11 alternative to the Java anonymous callback class

java,c++,c++11,callback,abstract-class
I realise that the solution I have here is far from ideal with C++, so I'm asking what a proper C++ programmer would do in this situation. (C++11) I have a DialogBox class, which stores a collection of buttons. At the moment I have a pure abstract inner class DialogBox::Button...

Resolve promise in service without callback in controller

angularjs,callback,controller,promise,angular-promise
I would like to ask/discuss wether this is good or bad practise - what are the pros and cons of making a service call insde a controller as clean and short as possible. In other words: not having a callback anymore but make use of the Angular binding principles of...

Use a function with parameters inside a callback

javascript,parameters,callback
I've written a function which may take an unknown number of functions as parameters, but can't figure how I can make this work when one or more of the functions take parameters too. Here is a quick example of what I would like to achieve: function talk(name) { console.log('My name...

How do you control callbacks and stop them from returning without using async?

javascript,angularjs,callback,control-flow
So I'm working on a project using Node and Angular (first project). Basically I want to get some content out of the database using Angulars $http service which calls an endpoint thats setup in Express that queries the database using Sequelize. Here's a snippet of each: Frontend App.js $http .get('/getmessages').success(function(data){...

callback = callback || function() {}; [duplicate]

javascript,callback
This question already has an answer here: Init object in javascript using || operator [duplicate] 7 answers What is the purpose of the above line of code. I'm specifically confused by OR-ing the 'function() {}'. Why the empty function? To give a little more context to the line of...

fs.writeFile callback never gets called, same for WritableStream.write, etc

node.js,callback,fs
I am writing a small text file (~500B) but, strangely, I get an empty file if I write using asynchronous methods such as fs.writeFile(..) (or WriteableStream's write/end method). This works: var scanInfo = getScanInfo( core ); // returns several lines delimited by \r\n fs.writeFileSync( filename, scanInfo, 'ascii' ); This creates...

How to pass python self object to another python script

python,callback
I have a strange requirement, in which I need to call a script from python, which I am doing using the subprocess module, and then call a function of original class from the script. I have something like this - import subprocess import textwrap import sys class caller: def call_script(self):...

How do I convert this code using promises?

node.js,callback,promise
I am new to Nodejs.I want to convert this code to promises (nodejs).This includes four callback function get(),abc1(),pqr(),xyz(). It gives error of "cannot read property 'then' of undefined" Can anyone fix it? I am trying it to convert into promises from this example here var jwt = require('jwt-simple'); var mysql...

How to write jasmine test for following angular service which uses API and call backs

angularjs,callback,jasmine
In my AngularJS application, I am having trouble figuring out how to unit test the following code: This is the service being used by my test controller: angular .module('web.template') .factory('testService', testService); testService.$inject = ['$http']; function testService($http) { return { getTestDatas: function (callback) { var data = { 'testParams': "test" };...

Audio player - sharing data between callbacks

matlab,audio,callback
I already asked this question to no avail. I couldn't solve the problem. I am trying again maybe someone can help! I have 2 buttons, Play and Stop. I would have the path of an audio track at hand and want the audio to play when the user clicks on...

“undefined is not a function” using callbacks

javascript,node.js,api,callback
I'm creating a twitter bot that is requesting from the same API, Wordnik, but each request is depending on the last request's results. So, I decided to try creating some code using callbacks to make sure that all of the information is returned from the API before the next function...

How do I use promises in node.js to clean up a chain of callbacks?

javascript,node.js,callback,promise,q
I'm trying to figure out how to use promises, particularly the Q implementation to clean up some messy nested callbacks in a node.js program. Unfortunately, there seems to be very few simple examples out there that illustrate what I'd like to do. Here is a simplified version of the nested...

Javascript Callback with Parameters and Return Value

javascript,callback
Here is my dilemma, I have a series of functions that get called and I am using callbacks to execute a function when they are complete. The callback returns a value and that works great too, my problem is when I add parameters to the callback I can no longer...

Accessing Individual Array Variables in PHP Function

php,arrays,callback
I have a function userNumber($number) where I want to return two variables. I know it's not possible to return more than one variable in PHP functions, so I created an array so I can access any index/value from the array when needed. The function tests if the user's input is...

How to pass argument to callback and don't lose bind?

javascript,jquery,callback,argument-passing
I have the following code: $.getJSON('getAllTerminals.json', renderTerminalsOnMapAndFitBounds.bind({index:globalRequestCounter++, navigateToTypedText:true})) ... function renderTerminalsOnMapAndFitBounds(data, updateSelectedTerminals) { renderTerminalsOnMap.call(this,data); fitBounds(); if(this.navigateToTypedText === true){ navigateMapToTypedAdress(); } if (updateSelectedTerminals) { $.getJSON('getSelectedTerminals', {}, function (json) { window.MARC.addTerminalPage.terminalsSelected = json; update(); initPage(); }); } } Can you...

How can I pass mochas done callback function to another helper function

javascript,callback,promise,mocha
I have a block of code that I will be using several times within a then statement in mocha so I turned it into a function. However I also need to call done()within that function and it's out of scope resulting in the error Uncaught ReferenceError: done is not defined....

Self as argument type of generic callback

swift,callback,associated-types
I'm trying to implement generic broadcasting function for each type that supports specific protocol. For example: protocol Proto { typealias ItemType typealias Callback = (Self, ItemType) func register(tag: String, cb: Callback) func unregister(tag: String) } class Foo : Proto { typealias ItemType = Int func register(tag: String, cb: (Foo, Int))...

async js callback for each upload

javascript,asynchronous,callback,angular-file-upload
I'm new at web develop. I was faced with the following problem: I upload images at amazon s3 and getting callback with response which contains link to this image. Then I push it into array and store this array in DB. But I don't know how to go to the...

starting activity from a callback method

java,android,android-activity,callback,intentservice
i use a class WebServiceAdapter using volley library for implementing http connections. since i can't find a way to return a string to activity i use an interface to callnback into MainActivity. in it i want to start a new activity but it is not starting my WebServiceAdapterClass public WebServiceAdapter(Context...

C++ Generalize delegates

.net,callback,delegates,c++-cli
i have a similiar situation: ref class Manager { delegate void answer1(String^ Message, int Avalue); delegate void answer2(Object^ Obj, double Something); answer1 ^ Callbackfor1; answer2 ^ Callbackfor2; void RegisterCallback1(answer1 ^ Address); void RegisterCallback2(answer2 ^ Address); } How can i manage that in a better solution? I had to create each...

When working with NodeJS FS mkdir, what is the importance of including callbacks?

javascript,node.js,callback,filesystems
I'm playing with the NodeJS REPL console and following this tutorial. http://www.tutorialspoint.com/nodejs/nodejs_file_system.htm I'm focusing on the File System(FS) module. Let's look at the mkdir function used for creating directories. According to TutorialsPoint, this is how you create a directory with FS var fs = require("fs"); console.log("Going to create directory /tmp/test");...

How to add custom attributes to function callback Javascript

javascript,callback,bind
I have this code doPurchase = function(amount) { transactionCompleteCallbackImpl.bind(this, amount); iclient.initiatePurchase({ amount: amount, cashout: '0', integratedReceipt: true }, { statusMessageCallback: statusMessageCallbackImpl, questionCallback: questionCallbackImpl, receiptCallback: receiptCallbackImpl, transactionCompleteCallback: transactionCompleteCallbackImpl }); }; I do not control the iclient code as it is loaded from an external source, however I wish to add the...

Cast between two slightly different std::map

c++,casting,stl,callback,stdmap
I have a std::map defined as follows: typedef void (SomeClass::*callback_f)(); typedef std::pair<std::string, callback_f> my_pair; typedef std::map<char,my_pair> my_map1; There are multiple of these definitions, so there is my_map1, my_map2, etc. and every one of them differs from the other for the class SomeClass, which is SomeClass, SomeClassTwo, etc. My need...

Passing a callback function in options object to other function

jquery,callback
I am surely doing it wrong and now I am stuck. What I want to do is to pass function as callback to another function. My function: function myfunc(options, callback) { var settings = { opt1 = "something", url = "someURL" } if( options ){ $.extend( settings, options ); }...

Mongoose 4.x “model.update()” callback changed

javascript,node.js,mongodb,callback,mongoose
Before mongoose 4.x, in update(), you can check the 2nd parameter in callback to see if the document is found. In example below, you can use "rowAffected" to see if there exists a document with username john. model.update({ username: "john" }, { ... }, function(err, rowAffected){ if (rowAffected) // document...

How to get variable from request in nodejs module

node.js,callback,request
I have the following two files and can't get the result out of my modules request into the var inside app.js. I thought about module.exports exports as callbacks but I can't find the right combination. // app.js #!/usr/bin/env node // i am a nodejs app var Myobject = require('./code.js'); var...

return an error from $http.success

angularjs,callback,promise
I am working in Angular and I need to signify an error to a promise further down the chain when the result is being resolved in .success(). I call a function in my service from my controller like myService.myFunction().then( function(results){ // do success stuff }, function(err){ // do failure stuff...

multiple return values in callback blocks

ios,objective-c,callback,block
people I am working with don't wanna use delegate methods for a couple of reasons and they want me to come up with a solution; basically they want a callback block with multiple return values, and when the first return value arrived block should still wait for the upcoming return...

Electron & ReactJS, Use BrowserWindow for GitHub oAuth authentication

oauth,callback,github-api,electron
I have set up github's Electron with ReactJs. So I got a BrowserWindow and a react app playing nicely in that window. What I'm trying to achieve is to get authenticated with GitHub. So when a user presses the Login with Github button, a new BrowserWindow opens and goes to...

.getScript() callback for multiple usage

javascript,jquery,callback,promise
If I have 2 JS files like a.js and b.js a.js $.getScript('some.js',function(){ //Call some function in some.js }); In file b.js, I will call function some some.js, but how to know that some.js is loaded ? Can I do something like.. (in b.js) SomejsIsLoaded.then(function(){ //Call some function in some.js });...

JAVA: RMI Callback -> object already exported

java,callback,server,rmi,stub
this is my first question, so sorry if i'll make it incorrect and for my english. I have to do a distributed-hangman project in java, there are guests, players and masters (more matches). When a user(already registered) log himself or when a master open a match, the server must notifies...

Why does a callback method needs to return something? [on hold]

java,interface,callback,return-value
I have never before seen such a thing, so let's say I have such listener object: MyWhateverListener dafuqListener = new MyWhateverListener() { @Override public void onSuccessCall(String s) { // success call } @Override public void onFailCall(boolean b) { // fail call } @Override public boolean onDafuqCall(int i, boolean b) {...

Waiting on asynchronous functions within multiple conditionals

javascript,asynchronous,meteor,callback
The meteor project I'm working on uploads files when certain conditions are satisfied. Regardless of whether or not the files are uploaded, a Meteor.call has to be made once the if statements have completed. Because of the conditionals, when I use callbacks it results in a lot of duplicate code....

How to remove a `tag listener` in Phonegap NFC plugin

cordova,callback,phonegap-plugins,nfc
I am using chariotsolution's nfc plugin for phonegap (https://github.com/chariotsolutions/phonegap-nfc) and it's all working perfect until the time came that I needed to remove a listener. I can't do it and it seems like it's not working. My question is, is this a common bug? Has anyone ever tried to remove...

Callback in a double loop

loops,callback
I have seen examples of callbacks inside a loop where the loop needs to wait for the callback and I don't get how to apply those answers to my script. I actually have a double loop like that: var marker = [{43.000,-79.321},...]; var result = []; function test(){ for(var i=0;...

Rails refactor/combine similar before_update callback methods into one

ruby-on-rails,ruby,ruby-on-rails-4,methods,callback
I’ve created some model callback methods that timestamp an attribute every time a file is created, changed or removed. I was wondering whether there was a more elegant way to write these callbacks, without having to repeat similar method code five times: before_update :quote_file_updated?, on: [:create, :update], if: ->(r) {...

How to add extra parameters to a function callback

javascript,node.js,callback,mongoose
I am using a few callbacks in an app that I'm writing. I am using Mongoose models and need to save a few different places. The save function takes a callback, and the callback gets error and model for its parameters, but I'd like to send the callback an extra...

Mutex Across Threads?

c#,multithreading,callback,network-programming,mutex
So, I am getting an exception with the code below. I have put the exception details with it, but I believe it is caused by the fact that a different thread releases the lock then the one that starts the lock. I want to do this to potentially allow my...

Function pointer in DLL call - how to handle in C#?

c#,dll,callback
I'm using a native DLL that is called out of my C# application. One of the DLL-functions is defined like this: int set_line(const int width,fct_line_callback callback) fct_line_callback itself is defined as typedef int (*fct_line_callback)(double power,void *userData); So how can I use this function out of my C#-application? Is there a...

Swift Callback change UIViewController Label

ios,swift,callback
I started to study Swift for IOS yesterday and I'm trying to make a simple login app. This is my swift file import Foundation import SwiftHTTP func printSomething (sentence: String) { println(sentence); } func makeLoginCall(user: String, pwd: String, doneFunction : (Bool) -> Void) { var url : String = "myurl"...

Is it possible to have two callbacks in around_destroy in rails?

ruby-on-rails,activerecord,callback
Although this can be accomplished as follows: class Model < ActiveRecord::Base around_destroy :callback def callback puts 'callback1 before yield' puts 'callback2 before yield' yield puts 'callback1 after yield' puts 'callback2 after yield' end end But I wish to do the following: class Model < ActiveRecord::Base around_destroy :callback1, :callback2 def callback1...

DialogFragment callback to Target Fragment using interface

android,android-fragments,interface,callback,android-dialogfragment
I am trying to send some data from a dialogfragment to the targeted fragment but its not working. I have written the following code, but it through exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.x.x.FragmentAlertDialog$Communicator.setI(java.lang.String)' on a null object reference Code: public class FragmentAlertDialog extends DialogFragment { Communicator callback;...

Is there a way to modify class state from a function pointer passed to a C API?

c++,c,class,callback,global-variables
I have a class that has some internal state. The class uses a C library called GLFW to deal with window managing and keyboard input. The class looks something like this: class Object { public: Object(...); ... private: int _member_variable; // Internal state GLFWwindow *_window; ... } Background about GLFW...

Return response from asynchronous call example

javascript,asynchronous,callback
I have read this stackoverflow post several times How to return the response from an asynchronous call?. For some reason, I just do not get it. Could someone post the example in the question here as an actual full working solution instead of the step by step guidance provided in...

Get animate().translation Callback When Animation Is Complete

java,android,animation,callback,translate-animation
I've been looking around and the main ways seem to be setting an animation listener on the object. However I have set an animation listener and the animation complete callback does not fire. Do you know how I can get the callback when an view.animate().translationY() has finished its animation? root.setLayoutAnimationListener...

Event in Maya Api to capture currentTime / frame change

c++,events,callback,message,maya
I am currently developing a Maya plugin. How can I set-up a callback that gets fired each time the frame number / current time is changed in the scene ? I had a look at the MSceneMessage Class, but it doesn't seem to contain what I am looking for....

How to click on a p:commandButton using javascript [duplicate]

javascript,jsf,callback,commandbutton
This question already has an answer here: How to select JSF components using jQuery? 2 answers There are many tag in my JSF page.I want to click a p:commandButton using javascript in one of the forms. But it doesn't work. When I debug it use chrome ,it prompt The...

how to get result which is returned with C callback in C++

c++,sqlite,design-patterns,callback
I am rather new to handle C callbacks in C++. I made a sqlite wrapper c++ class, which just calls sqlite3_exec(). static int callback(void *NotUsed, int argc, char **argv, char **azColName){ SqliteAccessor* sqlite = static_cast<SqliteAccessor*> NotUsed; if(argc > 0) { sqlite->set_table_exists(true); } return 0; } class SqliteAccessor{ public: bool has_table(const...

Javascript: Solving the asynchronous loop to push an array in Parse.com

javascript,arrays,callback,promise
I'd like to get the final result from a loop where I'm pushing objects into an array. I know from the console.log that all of the results go into the array but I can't get my desired array out of the double loop to use for anything. I understand that...

completion handler in method which request information from server

ios,callback,block,objective
I have a method which send request to server and i have created the call to that function with completionHandler as follows: -(void)sendAddSubscriptionRequest:(NSString*)owner withComppletionHandler:(void (^)(BOOL, NSArray *, NSError *))completion dataWebService = [[NSMutableData alloc] init]; NSURL* aUrl = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.google.com/add?"]]; NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:aUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [request...

Javascript callback() for two functions

javascript,callback
I have two questions regarding the callback on JavaScript. First: Does the for loop run asynchronously? That is, in the function: function postData(items, callback) { for(var i=0 ; i < items.length ; i++) { //angularjs Post request $http.post("http://www....", item[i]); } callback(); } Will the callback() wait until the cycle is...

Merging arrays with passing a function as parameter

javascript,merge,callback
I've been on this problem for about 3 hours and I can't figure this out. I've gone through Codecademy and Code School Javascript courses, and according to the blog that hosted this code block, I should know the answer: var merge = function(array1, array2, callback){ //your code here. } var...

Instagram Authentication no longer shows sign in inputs just serves instagram.com

authentication,callback,instagram
So I know that instagram just did some API updates which I am trying to implement. But the very first step no longer seem to work: https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code This very first step used to send you to a sign in page where you input your username and password, if you were...

Using callbacks in window.onload

javascript,callback
I think there is an easy solution for this, but for some reason I am not getting the expected results. My functions look like this: var functionA = function(callback) { loadData(fromURL1); // takes some time loadData(fromURL2); // takes some time callback(); // Should be called AFTER the loadData() functions are...

Registration program based on RMI with callbacks

java,callback,rmi
I have to make a program with the following requirements: Build a Client/Server application based on RMI with the following characteristics: The application is structured in 3 different projects: Server, Client, Shared where Shared contains interfaces and classes common to Server and Client. Server and Client are programs, each with...

Retrofit: Callback doesn't access succes and failure methods

android,callback,baseadapter,retrofit
I'm trying to do a HTTP-POST using Retrofit. I have done this successfully in other classes, but now it doesn't work. Maybe because I am extending BaseAdapter instead of Activity or Fragment like I did before , but when I call the POST method it doesn't even access the succes...

How to pass python function as an argument to c++ function using Cython

python,c++,callback,wrapper,cython
Here are my settings: I have next c++ class which I want to wrap: // Foo.h class Foo { public: typedef int MyType; typedef int ArgType1; typedef int ArgType2; ... typedef MyType (*FooFunction) (ArgType1 a, ArgType2 b); ... void setFooFunction(FooFunction f); Example of using this class in c++: #include "Foo.h"...

Function returning before async method done Node JS

javascript,node.js,express,callback
I currently have a function that is called from my router: router.js: var result = Api.getUser(); console.log("Result: " + result); api.js exports.getUser = function(req, result) { request.get({ uri: URL + '/user/me/', headers: {Authorization: 'bearer ' + req.user.accessToken}, json: true }, function(e, r, body) { console.log("e: " + e + "...

How to apply a callback to multiple elements?

javascript,arrays,json,callback
I have this following callbacks. But if I start my player is going to show me always the second callback. How can I make a callback and show both videos random? callback('{"video": {"mp4": "http://c0026122.cdn1.cloudfiles.rackspacecloud.com/193807.mp4", "webm": "http://5860e9e4db2f4cebe1e6-cc12bb9b5e092d34d0fadb7ce5f280a3.r47.cf1.rackcdn.com/193807.webm", "title": "Touch"}}'); callback('{"video": {"mp4": "http://c0026125.cdn1.cloudfiles.rackspacecloud.com/064915.mp4", "webm":...