Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [callback]

Callback is facility to save a piece of code so that it may be invoked later in the current environment (Typically in response to an event)

0
votes
1answer
102 views

Chaining ConstrainableSet<T> [on hold]

Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to ...
1
vote
0answers
40 views

C# asynchronous notification vector v2

As a result of my previous post, I have implemented / refactored my code and have started making successful use of my class. However I have come across a couple of new questions: The observer must ...
4
votes
1answer
93 views

Constraining a property setter fluently

The below code is aimed at providing you the most amount of control and flexibility with control which value gets set to a property. I Introduce to you, the ...
6
votes
1answer
82 views

C# asynchronous notification vector

The purpose of this class is to efficiently notify another thread when data is available with minimal blocking to access/pass the data. The data reader/producer thread processes data in bulk which ...
3
votes
2answers
82 views

Function to call a list of callables with retry

This script is designed to be run via windows task scheduler once per day. All callables passed to this function should only return a bool. The callables are called until either the maximum number of ...
0
votes
1answer
30 views

Updating one model field based on the associated model's field

I'm wondering if there is any way we can optimize the following code. Scenario is Library's active field should be ...
2
votes
3answers
160 views

Simple Publisher Subscriber in Java

I am new to Java and had some difficulty creating this simple Publisher Subscriber class. It finally seems to be working and I wanted to check if I have been following best practices and see if there ...
1
vote
1answer
380 views

C++ wrapper for GLFW window object

I'm creating a window class in C++ to provide a bit of abstraction for a GLFW window. window.h ...
0
votes
1answer
76 views

pass argument to jQuery .on() event handler callback [closed]

In my web application, a user will click a button which will call a function that triggers an AJAX call. That function accepts a single argument. I would like to be able to put that function in ...
6
votes
2answers
90 views

Event emitter npm module

I was asked to complete the task described below: Event Emitters are objects that serve as the core building block in event-driven architectures. They simplify the process of handling asynchronous ...
1
vote
0answers
75 views

Correct Callback for each item

I have added a correct question callback for different types of questions like: radio, checkbox and descriptive.. QuestionListActivity.class (it shows the list of questions to attempt) ...
3
votes
2answers
50 views

jQuery handler to update map UI based on AJAX response

I am working on a university project that consists of creating a map application with openlayers as well as the necessary User-Interface. I am using jQuery, native JavaScript, PHP and of course HTML/...
4
votes
1answer
440 views

Simple event dispatcher

Here is my very first event dispatcher. I would like to get both, style and code review, as well as some ideas to improve this implementation (new features etc.) I tried to write code in C++17 style ...
1
vote
2answers
50 views

Class that provides callback execution at a specified rate

Here is a class I wrote to provide a user a way to have a callback function executed at some defined frequency: Task.hpp ...
2
votes
1answer
166 views

Extracting data from vue-chartjs into an array of datasets

I have a function which returns an array of datasets for a chart written with vue-chartjs. The getter getChartData returns an array with three objects with nested ...
2
votes
0answers
45 views

Controller to execute AJAX requests for a client

I have been developing this structure or pattern (I don't really know how to call it). It's my first time doing something like this, and I'm a bit worried about the future, if it becomes unmanageable. ...
6
votes
1answer
1k views

Simple implementation of signals and slots mechanism using templates

I tried to implement a simple signal&slots mechanism for some DSP software that runs on embedded Linux. I would like if somebody can review this code and give me some guidelines. Any review and ...
3
votes
0answers
36 views

Apply arbitrary action during recursive generator function

I've got this recursive generator function. It will traverse an object looking for "leafs", any keys that don't point to sub-objects. Then it applies one of two actions on the leaf and yields it. Any ...
3
votes
1answer
194 views

Make HTML/Javascript Geolocation function more linear

I'm checking users locations with HTML Geolocation before unlocking the front door. Geolocation takes a few seconds in addition to the time it takes the user to approve it, so currently I have a ...
2
votes
2answers
75 views

addEventListener after fetched data

This is working code, but I want to simplify, correct, and improve the code. ...
4
votes
1answer
691 views

Callback pattern for handling socket response

I am in the process of learning go and am coming from a PHP, JS, and Nodejs background. I created a package that is a client which connects to a socket server and processes the data received from ...
4
votes
1answer
830 views

Custom ostream for a println-like function

I am writing a plugin in C++ that uses C API that gives me a single logging function with this signature: typedef void(*println_t)(const char* text); I want to ...
0
votes
1answer
45 views

Poké-permalinks

On Pokemon Fusion, I found it annoying that the webpage didn't automatically update the tab URL to the permalink when the fusion is changed, so I decided to write a UserScript to do that. After ...
2
votes
1answer
141 views

HMAC Middleware

I have been programming a middleware for my small application that verifies if an authentication header is present and verifies the HMAC present in it. I would like to know what I could optimize in ...
3
votes
1answer
2k views

Nested loop with synchronous and asynchronous behavior

The problem is as follows. I have an array of objects like so: ...
0
votes
1answer
46 views

Running arbitrary number of mongo queries in nodejs

I am faced yet again with a callback headache: Simply I need to return to the client the results of multiple mongo queries, the number of which I don't know in advance. In short: fetch the first ...
1
vote
1answer
903 views

Use callback style to start a worker thread and receive result in Qt

After using JavaScript for a while, I think callbacks are pretty good for asynchronous programming, but I haven't seen anything similar in C++. What I want to achieve is to start a worker thread from ...
2
votes
2answers
304 views

Read lines from file, calling a consumer function for each line

I wrote a function for iterating over a large file with performance in mind. It takes in an InputStream and reads until it reaches the end of the file. Whenever it ...
2
votes
0answers
279 views

C++ regex_replace with arbitrary function

This is a version of C++17 regex_replace that handles arbitrary functions to do the replacement, instead of using regex_replace'...
1
vote
1answer
1k views

C++ event system

I created a simple C++ event system. In my code Event_channel is a static class that wraps singletons that manages events per event type basis. Every singleton ...
3
votes
1answer
111 views

TimeoutManager: check whether a task has been finished within a given time

I want to make a helper class, which raises an event whenever something is not finished in a certain time. Example: my program sends out multiple network messages concurrently. After a random delay, ...
0
votes
1answer
37 views

Implementation of callback in database request

I am a complete beginner in JavaScript / Node.js / Express, but have some experience with php. I am trying to pass data from a SQLite database to the console. In my previous attempts, ...
9
votes
4answers
622 views

ViewModels Mediator with multiple generic callbacks

I'm developing a mediator for an MVVM application. This application lets employees file tickets with IT support to ask for help. The mediator communicates messages and triggers callbacks between ...
0
votes
2answers
124 views

Callback notation in a Mediator [closed]

I'm implementing a Mediator and I'd like to simplify the callback notation a bit. My mediator has Register and Notify methods : ...
3
votes
0answers
33 views

Nisse Server: Part 5 Handler

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Nisse Server: Part 2 Socket Layer Nisse Server: Part 3 Stream Layer Nisse Server: Part 4 Server As I mentioned ...
6
votes
1answer
155 views

Processing input in background while user is typing

Use case A GUI with 2 controls: An input control for text (a DNA sequence) that should be analyzed A result control that displays the analyzing result of the entered text The analysis takes 2-3 ...
12
votes
3answers
4k views

Partitioning an array based on a condition in Javascript

Using the array.filter function, I can efficiently pull out all elements that do or do not meet a condition: ...
5
votes
1answer
74 views

Function to foreach over an array

I made a very simple generic function to foreach over an array in C using a callback function: ...
3
votes
1answer
55 views

Function that calls a function with the terminal temporarily set to raw mode

I'm working through Build Your Own Text Editor, a walkthrough of the code to an extremely small text editor for a posix terminal in C, but I'm attempting to follow along in-the-spirit with OCaml. I'...
2
votes
1answer
214 views

Event Handler Registration in Java [closed]

I have a stateful object on which I'd like client code to be able to register many event handlers. These handlers have different signatures—they usually accept the originating object and some piece of ...
7
votes
1answer
592 views

Simple helper for making things “disposable”

I often write small classes to make undisposable things disposable so that .NET can handle something automatically, like stopwatches or logs. I thought why not write a small helper that can be used ...
3
votes
0answers
251 views

Simple C++11 Subject-Observer

Building on the answer in C++ class member callback simple examples, I've tried to put together a simple subject-observer pattern without needing to inherit a virtual Observer class. I also wanted to ...
4
votes
2answers
106 views

Initialising accounting groups

This deeply nested set of callbacks is very unreadable and I'm looking for ways to improve it: ...
5
votes
1answer
661 views

Request and callback design

I am just trying to improve my coding and designing skills in C++ and for that I am trying to solve same age old problem of mapping a http request to method. Could you guys please look at my program ...
1
vote
1answer
98 views

Using JavaScript callback to conditionally send email

I have an app where users at some point select the amount of tasks they have completed. If they have only completed 3 or less then 3 tasks then I send an email to the system admin to inform them. But ...
1
vote
0answers
36 views

Cleanest way to write a callback that accepts a next sequence in javascript

I need to call multiple functions asynchronously before producing a result. In this case what are the possible improvements in the following code(also including other library like for promise etc.) ? ...
9
votes
1answer
1k views

Simple callback wrapper for an embedded C++ app

I'm writing a callback wrapper class for an embedded application in C++11. The basic idea of the class is to be able to use it as a replacement instead of C-style callback functions, with the added ...
1
vote
0answers
166 views

Chainable futures in Python

Here is a homemade Future class: ...
2
votes
1answer
412 views

Callback class to callback member (virtual) functions

After looking at a post on CR I found that pointers to member functions are incredibly hard to use, especially as callbacks. The current solution doesn't solve the problem mentioned in the linked post,...
1
vote
1answer
1k views

async.waterfall call

Does anyone have any recommendations for how I could make this async.waterfall call neater? Ideally I'd be able to do something like: ...