Skip to main content

Questions tagged [callbacks]

A callback is typically the address of a function or method or lambda expression provided when invoking an API. When an action completes, the expression is executed or "called back". Asynchronous APIs use callbacks to notify the calling function when an operation is complete. Use this tag for questions involving asynchronous APIs requiring a call back expression. Use the tag event-handling for questions on registering or subscribing for events, e.g. GUI.

6 votes
6 answers
1k views

Is a callback function with `this` as an argument a bad practice?

I have a class that has a callback function that gets triggered on some event. The user of the class instance is expected to do stuff on the instance itself, inside this callback function. So I am ...
doca's user avatar
  • 245
0 votes
1 answer
372 views

Implement Dependency Inversion in C with UML diagram

As per Robert C. Martin in Clean Architecture, he gives a simple UML diagram to illustrate Dependency Inversion. To put it simply, HL1 initially referred to ML1 without interface to invoke F() ...
Andy Lin's user avatar
  • 185
-1 votes
3 answers
671 views

What happens in terms of call stacks when 10000 setTimeouts are called?

Say we call 10000 setTimeouts, each with a random time, each with a few nested timeouts too. What happens in terms of the 1 call stack, or are there multiple call stacks? How does that work? So for ...
Lance's user avatar
  • 2,615
0 votes
2 answers
72 views

Setting custom callbacks in a Javascript applet?

I'm designing a 3D visualisation applet in Javascript. When used, a Canvas will be created and placed inside an HTML element on a webpage, specified by the developer who is implementing the applet. ...
Okarin's user avatar
  • 109
0 votes
1 answer
552 views

Object Oriented Design of Callback Methods

Assume that there is a library and it provides an interface to its users in order to callback them. Users implement this interface and receive notifications from the library. Let's say, ICallback is ...
Ricardo Cristian Ramirez's user avatar
6 votes
1 answer
2k views

What is a "tear-off" in software design or patterns?

What is a tear-off? I ran across the term reading Flutter documentation: Returns a CallbackHandle that can be provided to PluginUtilities.getCallbackFromHandle to retrieve a tear-off of the ...
Pete Alvin's user avatar
4 votes
0 answers
237 views

How to authenticate third-party callbacks that don't support authentication

I'm working on a project that integrates with a third-party service via API, and the third-party uses callbacks to update us on the status of the operations being performed. These callbacks can be hit ...
Omar Rida's user avatar
-2 votes
2 answers
125 views

Should I call a callback for an event triggered by a developer?

I'm designing an API for a stream-processing library. The library will process a stream provided by the user and will transition between states based on the data in the stream. The state transitions ...
awelkie's user avatar
  • 113
1 vote
3 answers
340 views

How to calculate overall progress in independent phases?

When using a call-back to show progress on a multi-phase task, I don't know how to calculate the progress per phase well. One of the phases is collecting data, which differs in size from run to run. ...
virtualnobi's user avatar
3 votes
2 answers
234 views

Callback pattern - return value confusion

I have a ConstraintsResolver class which resolves a queue of Constraints. This is done when a ConstraintsResolver object calls meetConstraint() on a Constraint one. Most of meetConstraint() ...
Themelis's user avatar
  • 139
2 votes
1 answer
118 views

For a use once only button callback, should the name be more related to the button or the task of the callback?

Suppose I have UI like it: <script> var someFunction(){ //some code to validate and then send message } </script> Message:<br> <textarea></textarea><br> &...
ocomfd's user avatar
  • 5,712
1 vote
3 answers
2k views

Callback injection

I have a service that needs to make a callback. Basically, it is an event that is expected to be handled in exactly one place, and that is too important to be optional. The obvious approach seems to ...
Timo's user avatar
  • 382
1 vote
1 answer
723 views

Should I replace switch case of functions determined by options in previous activity?

For example, assume my app has 3 steps with 3 pages: Step 1 : MainActivity: choose color Step 2 : EditTextActivity: input text Step 3 : GreenActivity: display color and input text In ...
ggrr's user avatar
  • 5,783
1 vote
1 answer
4k views

Is it a good idea to use my own callback mechanism instead of standard implementation like startActivityForResult?

I am trying to create a simple app which has 2 activities, which enter text on one activity and then displays it on the title bar if another activity: EditTextActivity: MainActivity: I know the ...
ggrr's user avatar
  • 5,783
1 vote
1 answer
1k views

Best practice to callbacks in OOP (JavaScript)?

For anyone who uses callbacks, how do I approach it when the method is an asynchronous setter? Here's an example class API { constructor() { this.token = null; } refreshToken(callback) ...
Vic's user avatar
  • 171

15 30 50 per page