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)

Filter by
Sorted by
Tagged with
3
votes
1answer
65 views

Callback C++ Class method from C

I am trying to callback C++ class methods from C. Now I have got something working, but am not sure if this is the best solution. I am looking for feedback, as to if there is something wrong with this ...
1
vote
0answers
22 views

AIPlaylist: Adaptive media player using VLCJ and Swing

I created a project using VLCJ and a probability function to create a media player that plays your favorite media more often than the others, because I wanted to hear my favorite music and videos more ...
0
votes
1answer
45 views

Registering a user and login

I have these following controller functions for registering a user and login, in my app, and I want to make it more clean and maintainable. Probably by using ...
5
votes
2answers
275 views

Message Broadcaster

I've written a basic event messenger broadcasting service. This is meant to allow for broadcasting events between loosely coupled areas of code where you may not have or care about a direct reference ...
3
votes
1answer
46 views

Callback usage with custom Stack Exchange Flair

Today I decided to continue refining my JavaScript skills and utilized the Stack Exchange API (v2.2) to write a "user flair" replica. In case you don't know what the flair that SE provides is: The ...
3
votes
2answers
76 views

callback function with no dynamic memory allocation

I tried to make a callback type for embedded, I know std::function and lambda but I know that there is some dynamic memory allocation that I want to avoid, I came ...
4
votes
1answer
176 views

It's Teetime; adding tee like functionality to Popen

I recently needed to run some command line applications from Python. Whilst this is fairly simple with subprocess.Popen. I wanted to be able to properly pipe the ...
3
votes
1answer
1k 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
98 views

Bitmask, How to abstract those callbacks in this implementation

I've made an POC about a bitmask implementation in order to replace a huge if/else statement. Those statements are about strings and I have almost 15 /20 string to test. Depends on values the if/else ...
5
votes
2answers
100 views

Simple replacement for Redux in ES6

The idea about this code is that it's a full replacement of Redux — in 22 lines of code. ...
7
votes
1answer
57 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 ...
2
votes
0answers
22 views

UI Event Flow class

Purpose: I wanted a way to improve event clarity and event code organization. I observed that every single event flow went through the following steps: Trigger -> UI Change -> (Async) ...
12
votes
2answers
1k views

Implementation of a Thread Pool in C++

I wanted to implement a thread pool to test my knowledge of various modern C++ features. The end result could be better, but I need a review as I'm not sure about delicate things especially regarding ...
2
votes
0answers
23 views

Customizable unidirectional questionaire in javascript

I wrote the below answer for the following question on SO a couple of days ago, and I was curious if the usage of the generator function is an acceptable one. I choose the generator function, because ...
4
votes
1answer
118 views

Wrap a callback method in an awaitable method

I'm using a .NET library which uses a pre-async/await type of asynchronicity. That is, it provides asynchronous (non-awaitable) method with a callback parameter. I'm trying to write awaitable ...
3
votes
1answer
74 views

Ajax function with a callback

I have Ajax function with a callback which fetches all the Patient data however I have some perfomance issues and trying to figure out what it might be, does anyone have idea? That's my Code ...
1
vote
0answers
56 views

React.js hook to validate a form on submission

I am fooling around with hooks in React and I'm stumbling against decisions that I need to make regarding implementation. Below is the code for the custom useForm hook which can be used to hook up ...
3
votes
1answer
97 views

std::function alternative with no dependencies

An alternative to std::function for when compile time is more important than runtime performance. Doesn't pull in any headers. (...
0
votes
0answers
58 views

Helper to convert arbitrary function into a custom deleter

If you want to use a custom deleter in unique_ptr you either have to pass a functor or the signature of a delete function as template argument. If you have a ...
1
vote
0answers
18 views

Creating a reusable plugin (Dialog/Notifier as example)

I started working on a notification system that is pluggable into any project. I have not made any "plugin" type javascript libraries, usually just functions very specific to the project at hand. That ...
0
votes
1answer
110 views

Chaining ConstrainableSet<T> [closed]

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
55 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
108 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 ...
10
votes
1answer
605 views

ActivityLifecycleHelper implementation

Description The ActivityLifecycleHelper uses wrap(Context)to create the class and save a global ...
6
votes
1answer
94 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 ...
4
votes
2answers
5k views

Flattening multiple nested node readline questions

Say I'm creating a simple CLI. I want to use native node readline module to take in some input from user at prompt. I thought of this: ...
4
votes
2answers
103 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 ...
3
votes
3answers
2k 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
1k 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 ...
5
votes
2answers
112 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 ...
0
votes
1answer
170 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 ...
1
vote
0answers
83 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
1answer
59 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'...
3
votes
2answers
68 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
1k 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
61 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 ...
0
votes
1answer
50 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
0answers
50 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. ...
2
votes
1answer
297 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 ...
6
votes
1answer
2k 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 ...
22
votes
3answers
12k 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: ...
2
votes
1answer
292 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 ...
4
votes
1answer
1k 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 ...
2
votes
2answers
163 views

addEventListener after fetched data

This is working code, but I want to simplify, correct, and improve the code. ...
8
votes
2answers
4k views

C-ifying a capturing lambda

What do you think of this code? ...
5
votes
1answer
2k 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 ...
2
votes
1answer
161 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
3k views

Nested loop with synchronous and asynchronous behavior

The problem is as follows. I have an array of objects like so: ...
0
votes
1answer
51 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 ...