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)
2
votes
1answer
48 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 ...
9
votes
1answer
451 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 ...
2
votes
0answers
26 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
93 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
74 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
50 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
33 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.) ?
...
8
votes
1answer
227 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 ...
0
votes
0answers
47 views
1
vote
1answer
79 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,...
0
votes
1answer
49 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:
...
7
votes
1answer
63 views
ActivityLifecycleHelper implementation advice
Description
The ActivityLifecycleHelper uses wrap(Context)to create the class & save a global ...
-3
votes
1answer
162 views
Example of Callback Hell [closed]
I am trying to come up with a minimal example of what is known as callback hell in JavaScript (so this would be a bad code review I guess). This is what I have so far, and I would like it to also run ...
3
votes
2answers
93 views
Callback system for events in a window
I have written a simple window event capture wrapper that gets events that happen to the window, and can be checked anywhere in the program through a global class. I wanted to be able to create a ...
1
vote
2answers
73 views
Avoiding nested callbacks when using MongooseJS
I'm diving into the world of nodejs and mongo. I am playing around with a simple app that uses MongooseJS to talk to Mongo. I have been looking at examples and some GitHub projects for references, but ...
0
votes
1answer
80 views
JavaScript multiple ajax calls but can either be one or two
I'm writing a piece of JavaScript to make one or two ajax calls. There will always be one ajax call fired but it might be two based on cookie setting. If user is logged in then we call another service ...
0
votes
0answers
54 views
Call Specialized Callback from Generic Object
Purpose: The intention behind this code is to have multiple applications that each implement an Actor. Each application should be responsible for defining which actions the given Actor should ...
5
votes
2answers
84 views
Swapping dynamically populated images on hover/touch
I'm using jQuery to swap images on hover. There's a main image, and a gallery of thumbs. When the thumb is hovered over/touched, the larger version of it populates the main image, and the smaller ...
0
votes
0answers
29 views
Using Async.js 'auto' method, checks two different databases/sources for matches, and manipulates the final results
Is there a way to abstract the final callback of the async.auto section of the testZip function below? My issues is that that I am repeating that section as the callback for a handful of other ...
3
votes
1answer
103 views
From Callbacks to Promises - MEAN Stack
I have a MEAN Stack app in which I have been using mongoose routes to update my data. Some of those routes have a lot of back and forth in terms of updating data across multiple users and collections. ...
1
vote
0answers
34 views
AJAX Form Creator
I wrote an AJAX Form Creator (in the form of an js object constructor) that takes a form and a callback. I am a decent, slightly okay, completely novice developer, and could use feedback on coding ...
3
votes
1answer
69 views
Input-reading library for Node.JS
Recently I have been busy with nodejs and I thought to create something like this Java input library, so I started with some rough code like below:
...
0
votes
1answer
429 views
How to flatten 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
1answer
59 views
Invocation list implementation (signals/slots)
This class is mostly an educational exercise for me using some C++11 constructs. I wanted to create something similar to an "invocation list" in C#, i.e., a list of zero or more function objects which ...
1
vote
1answer
297 views
TCP client library using Winsock WSAEventSelect in C++ - Take 2
This is my second take on creating a tcp client C++ class. The class declaration is general but the implementation is Windows only at this stage and uses the Microsoft Winsock WSAEventSelect model.
...
3
votes
1answer
204 views
TCP client library using Winsock WSAEventSelect in C++
One way to write a client which uses a specific protocol, eg http like in this case, is to create a base class with the basic socket handling functionality with virtual functions which can be ...
1
vote
0answers
45 views
Saving parsed CSV data to MongoDB
I wrote a script for reading a CSV, parsing it and saving data to MongoDB. I would love some input on how I'm handling errors and dealing with callbacks. I wrote it with nested without using async and ...
2
votes
1answer
70 views
1
vote
0answers
252 views
TinyMCE plugin to save with cancel button
Please provide constructive criticism for this TinyMCE plugin which allows the user to save the content, or cancel and go back to the original.
JS Bin
...
3
votes
1answer
28 views
JavaScript idle managing structure
I am just getting into the world of javascript, coming from the world of classical inheritance. The following is a library I wrote to track when a webapp is idling and I wrote it like I write ...
2
votes
0answers
324 views
C++ UDP server for a game
I broke my server into two classes, a general server class and a client session class.
I know the code isn't documented in the header, but I am more interested in the design of the server/session ...
2
votes
1answer
26 views
Parallel computation to be merged, depending on single call
Steps:
Get AMOUNT from a call to API endpoint /a, e.g. AMOUNT == 5 (in the code it is set ...
4
votes
1answer
278 views
PHP Route class
I was trying to keep it SRP. I'm new into PHP OOP and I'm wondering how I can make it better.
Route.php
...
0
votes
0answers
31 views
Generic Timeout Handler
In a frontend Javascript project I have to implement a generic timeout mechanism for a set of asynchronous tasks that the program needs to perform.
These are the conditions:
The tasks are functions ...
6
votes
1answer
522 views
C++14 Event System
I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below.
It is still a work in progress and uses some not-...
4
votes
2answers
146 views
C++ EventHandler class, invoking & arguments
This is my EventHandler class, which is extremely simple and can be used on lambdas and similar:
...
6
votes
1answer
94 views
Rate limiting function calls
I wanted to write a function that when applied to another would rate limit it, but permit all calls to eventually make it through.
Comments and criticism welcome.
...
2
votes
1answer
88 views
Handling success and failure when retrieving product information
I've got an Angular controller where I have two functions that are repeated inside two functions:
...
0
votes
1answer
152 views
Operating on a list of files using recursion
I'm starting just now with CoffeeScript and I found out that I can't solve problems like looping and recursives with just one line. I would like to improve the code that I just wrote using built-in ...
5
votes
1answer
55 views
Process chain approach
I've been researching about JavaScript and jQuery function chaining and different callback techniques. I am trying to create a very generic code that allows chaining, and in a way that I may create ...
11
votes
1answer
486 views
Callback in Linux kernel driver in order to hide device's low-level protocol
I'm am writing a Linux kernel driver for HD44780 LCDs connected via I2C bus. In my last change I tried to decouple low-level code (which talks to the device via I2C) from device's logic (printing ...
1
vote
1answer
93 views
Taking and saving pictures using promises
I have the following 4 functions that work, however, I am sure that utilising promises will improve my code. I just find them so confusing.
...
12
votes
2answers
6k views
C++ Observer design pattern implementation
I'm using the Observer design pattern in order to manage events in the game I'm currently developing.
I based myself on the implementation demonstrated here but improved it in order to ease its use.
...
2
votes
1answer
1k views
5
votes
1answer
514 views
Avoiding callback chaining in authenticator
I'm developing an iOS Application in Swift that uses Google Cloud Endpoints as its backend. For now, I've just written the code for the user to login with his Gmail account and I've refactored it as ...
2
votes
1answer
310 views
Handling callbacks when doing async programming and dealing with scope
I'm using HapiJS to create a little backend for my side-project. In grabbing RSS feeds, I want to loop through my list of website URLs, grab the correct RSS links in the ...
5
votes
2answers
884 views
Synchronization in an event manager
I'm working on an event manager, and I am wanting it to be a tool developers use. It is lightweight and it uses annotations to register events. I've tried to set up ...
4
votes
4answers
64 views
Indenting a function to recursively find filenames
I wrote this function that recursively traverses a given directory resolves
the relative file-names to absolute file-names and yields the resolved file-name if it matches a given pattern. You can ...
2
votes
1answer
117 views
Conditional callback for asynchronous file copy
I'm trying to figure out the most elegant solution to do the following asynchronously using JavaScript (specifically node):
Given a destination file name, check if it is a directory
If it is a ...
7
votes
2answers
2k views