Most voted "callback" questions
74 questions
Sort by count of
-
177
votes4
answers72185
viewsWhat is a callback?
I see in many codes and even architectures the word callback, I see that it is in Javascript functions. But what is? How is it used? Why? I’d like an example of real use.…
-
23
votes3
answers2439
viewsWhat is the real advantage of using a Callback and what is thread/multithread?
There is a lot of explanation of what callback is on the net and even a few scant examples, but nothing that explains in practice and in detail a really important use (I did not find). I already…
-
18
votes2
answers1866
viewsWhat’s the hell with callbacks?
Going through some recent research, I came up with an unknown term for myself: "The callback Hell" or "The hell of the callbacks". I was curious and decided to research a little, arriving at the…
-
7
votes1
answer118
viewsHow to adapt a function that only accepts callback to the promise interface in Javascript?
I’m using an external library function to acquire the token of a user, it is the following: export default function GetGraphToken( email: string, password: string, callback: (graphClient: Client,…
javascript typescript asynchronous promises callbackasked 3 years, 11 months ago Matheus Wallace 73 -
5
votes1
answer5766
viewsDifference between onClick commands in React
When it comes to callback functions in Reactjs, what is the difference between the options below? onClick={() => this.onFunctionCickCall()} onClick={this.onFunctionClickCall()}…
-
5
votes1
answer504
viewsAngularjs - What is the best practice when uploading images?
I implemented this solution to upload images: MaquinaResource.save($scope.maquina, function (data, responseHeaders) { var formDataImage = new FormData(); for(var i = 0 ; i < $scope.images.length;…
-
5
votes2
answers172
viewsWhy don’t I need to declare the parameter in the function?
In the React documentation he brings an example of form, when the input receives some property value onChange is called with the function handleSubmit(event) in that way onChange={this.handleChange}…
-
3
votes1
answer62
viewsScope in asynchronous call (Javascript)
Suppose I had the following method: this.loadCustomers = function(){ Request.get("php/loadCustomersAction.php", (function(error, data){ if(!error) this.setCustomers(data); }).bind(this)); }; where…
-
3
votes2
answers1059
viewsJSON API Callback
I have a question as to how to filter results from a API, and I wonder if anyone has had this problem before. Let’s say we have to access a API which is on a server other than ours and which returns…
-
3
votes2
answers77
viewsHow to get the instance itself (this) in a callback?
class Cat { constructor(name, picture) { this.name = name; this.picture = picture; this.count = 0; // ... this.img.click(function () { this.count++; // não funciona como eu espero }); } } Watch the…
-
3
votes1
answer94
viewsWhat is callback server-to-server?
I wonder if it is a concept, I am using a service that informed me that information can be obtained via callback server-to-server, but I did not understand exactly the meaning of the term.
-
2
votes1
answer103
viewsCallback after moveCamera on Google Maps
I have a Pageview that, in one of its Fragments, houses a Mapview with a map in "Lite" mode. Clicking on this map, a second Activity is launched (startActivityForResult) which consists of a complete…
android google-maps maps google-maps-android-api-2 callbackasked 9 years, 8 months ago Rodrigo Borba 121 -
2
votes4
answers1708
viewsPass javascript object by parameter in ajax callback
I know how to string: onclick="popularEdicaoRetrofit(\''+data[i]+'\');" and number: var criarRetrofit = onclick="criarRetrofit('+data[i].idRetrofit+');" I would like to know how to step an object as…
-
2
votes1
answer195
viewsHow to make is_unique two fields?
I’m in a need I don’t know how to accomplish. Well, my problem is: I have a field is_unique which refers to two fields of my BD, the IDENTIFIER and the PLAN. I would like to know how to carry out…
-
2
votes2
answers31
viewsHow to remove Level 1 keys using only one Callback method
I don’t want to use foreach and neither for. For example, I have the following array structure: Array ( [0] => Array ( [0] => Array ( [id_usuario] => 1 ) [1] => Array ( [idade] => 21…
-
2
votes1
answer200
viewsSynchronous Creation of Android Surfaceview
I created a subclass of Surfaceview to abstract canvas operations, such as drawBitmap (among others), as shown below: public class MyView extends SurfaceView { public MyView(Context c) { super(c);…
-
2
votes1
answer2727
viewsHow does callback work in PHP?
I was studying a little PHP until I came across this code: $this->form_validation->set_rules("nome", "nome", "required|min_length[5]|callback_nao_tenha_a_palavra_melhor"); public function…
-
2
votes1
answer140
viewsLogic with callback
I am with a small problem and I would like a help to understand and if possible an indication from Srs to help this problem. Let’s start, currently I have a loop, I’m doing it in a been getting…
-
2
votes0
answers108
viewsAre promises supposed to replace callback functions?
As Promises replace the functions of callback? Or the Promises are used only in asynchronous functions?
-
2
votes1
answer159
viewsProblem when executing a query in a repeat loop on the Mssql Node
So, I am using Node and mssql package (sql-server) to perform queries to my database. however I am facing a difficulty to return queries that need to be executed within a repeat loop. Maybe it’s…
-
2
votes1
answer170
viewsNode js, promises, callback
I need to run certain updates and delete within a query return in my controller. but only the last function is executed I don’t think I understand how to use promises. api.adMaster = function (req,…
-
2
votes2
answers67
viewsHow to execute a function whose name was passed as a parameter of another function, à la callback?
I created this function in order to abstract the calls $.ajax() to be performed at various different times. One of its parameters is the name of one of the functions I would like to be performed in…
-
2
votes1
answer164
viewsUnderstanding the scope of Arrow Function + callback
I would like to have access to the value of a variable returned from a callback outside of the callback function, and I would also like to understand why there is no syntax error when I try to use a…
-
2
votes1
answer290
viewsWhy does this function not return values
I am doing a more generic function to perform AJAX calls, in which I put the URL that should be searched and the data that it should send, and I wait as return the loaded data. However, I’m not…
-
2
votes1
answer72
viewsHow to convert a Promise-based function to callback in Javascript?
We can convert asynchronous functions that work with callback to work with Promises, as shown in the examples below: callback: const timeInMs = 1_000; function asyncCallback(timeMs, callback) {…
-
1
votes3
answers115
viewsMultiple callbacks with Javascript
Hey there, guys. I have two callbacks of distinct functions that provide me values that need to be used outside of these functions. Follow the code: FB.api('/me', function(response) {…
-
1
votes0
answers218
viewsCallbacks that don’t get in my head!
Guys I’m trying to get the concept of callbacks before you start studying NODEJS. But I can’t really understand the syntax of callbacks... it’s just passing a function by parameter? função1…
-
1
votes1
answer317
viewsCallable keyword in PHP
The keyword callable was implemented from PHP 5.4. It provides a way to type an argument from a function, requiring the type of argument to be a callback. Example: function minha_funcao($a, callable…
-
1
votes2
answers102
viewsHow to assign the callback variable "cursor.toArray(err, doc)" to an external variable?
var result = []; var user = db.collection('user'); var cursor = user.find(); cursor.toArray(function (err, doc) { result = doc; }); console.log(result); // console ->…
-
1
votes2
answers530
viewsRecover return from callback
I have the function below that calculates distances using a Google API. I would like to know how to have the return of the function of callback. <script type="text/javascript"…
-
1
votes1
answer244
viewsHow to wait for Javascript callback
I have a problem, I know because of how javascript works, but I do not know how to solve the problem. I’m using Cordova and a function need to use the Phone permission on Android. So before…
-
1
votes1
answer171
viewsHow do callbacks and anonymous functions work in PHP?
Good afternoon, How an anonymous PHP function works? How does the callback in PHP? How to work the two together? (anonymous and callback) I studied a little Javascript and found it very different in…
-
1
votes0
answers28
viewsIs this function using the concept of callback?
var array = [1, 2, 3, 4, 5, 6]; var arrayDobrado = array.map(function(num) { return num * 2; });
-
1
votes2
answers107
viewsHow does a function know how to take the elements of an array if they are not being passed to the function?
Hello, the following code is correct, but I would like to understand one thing: const Carros = ['Mercedes', 'Ferrari', 'BMW'] function imprimir(nome, indice){ console.log(`${indice + 1}. ${nome}`) }…
-
1
votes0
answers19
viewsPTBR FATAL EXCPETION:main java.lang.Runtimeexception - window get call back
I am making an application that needs to swap between screens and appears the following error: early java.: package com.example.deadsec.gerflores; import android.content.Intent; import…
-
1
votes1
answer40
viewsPass parameters to a function being passed from parameter to parameter
Imagine this, I have the function 1 that needs to receive as a parameter a function callback. Function 2 needs to receive a parameter and I need to pass it as a function value1, as I would pass this…
-
1
votes0
answers18
viewsHow to pass parameters to callback functions in javascript HTML events
Hello, good evening, I’m having trouble with callback functions in javascript and need help. The following lines below deal with rows in an HTML table, if the element present in cell2 is a composite…
-
1
votes1
answer828
viewsHow to update the value of a variable within a callback?
I am creating a module with Nodejs and in this module I created a function that returns a value, being this value updated within a function of type callback. The problem is that this variable/value…
-
1
votes0
answers52
viewsJavascript - Control of callbacks
I don’t really know how to ask this. I don’t know much about JS, but come on... The system here has an API that adds and manages elements on the screen. For example, just to illustrate: if I put…
-
1
votes1
answer42
viewsJavascript - It is possible to have a universal ordering function
I have an object called report and I have a report vector and I need to do several sorts, so I thought I would do an ordering function that was "universal". I wanted to be able to pass the attribute…
-
1
votes2
answers53
viewsEnable button when last request is executed successfully
Personal I am wanting to enable a button only when the last post request via Ajax is executed successfully. I have a table with several records with their respective information and ids. By clicking…
-
1
votes1
answer421
viewsCallback as return of argument
My question is this, from what I understand callbacks are functions passed as parameter that will be executed when some instruction is performed, but I often see the callback as a reserved word to…
-
1
votes1
answer61
viewsCalling more than one callback at the same time
I need a Workerclass that generates sequential numbers to print through a Callback interface these numbers in Mainactivity and a Segundaactivity when opened. My problem is that when Segundaactivity…
-
1
votes0
answers46
viewsWhen we use async don’t you need to use callback?
I have the following function in V10.6 nodejs: #func-1 module.exports.funcOne = (event, context, callback) => { callback(null, { message: 'funcOne', event }); }; #func-2 module.exports.funcTwo =…
-
1
votes1
answer33
viewsHow to make a function run after another? JS (Jquery)
I have the following functions: Grab server data by ajax and save to an object array: function carregaPesquisaTabela(){ controlLoading(); $.ajax({ url: "header.php", type: "POST", dataType:"json",…
-
1
votes2
answers421
viewsJavascript - error callback is not defined
I’m running a few asynchronous functions, who receive a callback, this callback gets as parameter a Boolean(true or false). When executing I have the error callback is not defined. [code] file -…
-
1
votes1
answer20
viewsWhy declare the timeout ID outside the callback of the mocking function?
This is a function that prints in the console what I type in the input. I would like to understand why, when I declare the ID of the setTimeout (in that case called time) outside the function, it…
-
1
votes1
answer62
viewsI fell in a Callbackhell?
My class is consuming a weather webservice through the method _interceptaClima(). Notice that I’m treating the answer through callbacks. The problem is that in the method calculaDesafio(), where I…
-
0
votes1
answer110
viewscallback from a server
People, I am involved in a project that requires the use of the Fitbit API. In my code, I redirect the user to the FITBIT site to authorize the use of the data. After authorizing, I need to grab the…
-
0
votes0
answers307
viewsIs it possible to return a value within a callback without another callback?
Well, I have a function that returns a value for a callback, but I wanted it to return without that callback, this is possible? Function in question: function getProfile(id, fn) { var sql = "SELECT…