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)

learn more… | top users | synonyms

1
vote
2answers
52 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
40 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
42 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
76 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
21 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 ...
1
vote
1answer
58 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
29 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
64 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
110 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
51 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
84 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
87 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 ...
0
votes
0answers
21 views

Handling callbacks and errors Nodejs

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
40 views

Recursively walk directories with a callback function

This code works, but I want to refine it: ...
1
vote
0answers
49 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 ...
2
votes
1answer
17 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
189 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
23 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
168 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
27 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
320 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
88 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
80 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
63 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
150 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
348 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
87 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
4k 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
857 views

Python lazy dictionary

Here is a lazy dictionary with test cases. ...
5
votes
1answer
454 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
230 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
666 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
57 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
107 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

C-ifying a capturing lambda

What do you think of this code? ...
2
votes
1answer
761 views

Inactivity Timeout

I made this piece of code to detect inactivity on different aspects of my app. It is part of a set of pieces to analyze user behavior. Not saying it's ugly, but good looking constructive criticism to ...
1
vote
0answers
59 views

Using an asynchronous function without directly using its callback

I hate functions and re-writing callbacks by "intercepting" them and passing the original along. This is simple: it uses an existing function, exec, and doesn't ...
6
votes
1answer
720 views

Callback functions to select the tab to the left in Google Chrome

I'm a JavaScript rookie, but I wrote a JavaScript function as part of a Chrome extension that will activate the tab to the left of the currently active tab. The function is pretty ugly, but I couldn't ...
5
votes
1answer
57 views

Organize JavaScript for video player controls

I have a small piece of code, and the problem is that I don't know how to organize it. There are tons of tutorials about JS code organization but I feel that those are for large scale apps. Also, I'm ...
2
votes
1answer
46 views

The best way to place callback definition [closed]

In JavaScript we can write callback definition in many different ways: Definition after usage: ...
1
vote
3answers
73 views

Type determined return values

I have the following js code: ...
2
votes
1answer
549 views

Angular callback scope.apply

Usually the socket.io's on method is like this: socket.on('/msg', function(data){}); But in Angular that callback has to be ...
1
vote
1answer
4k views

Using callbacks in a Restangular service

I have a project built with AngularJS and using Restangular in my services to handle API requests. The problem is I haven't found a good way to test the services which I think has turned into a bit of ...
2
votes
1answer
111 views

Observable storage - revised

Previous question: JavascriptObservable Storage The idea is to have some storage interface that exists of different buckets - known as Eagles: ...
8
votes
2answers
229 views

Concurrent Task Waiter 2

This is an iteration of my previous question: Concurrent Task Waiter Summary from before: I have some code designed to simplify managing multiple asynchronous operations. The code creates ...
1
vote
1answer
155 views

Concurrent Task Waiter

I have some code designed to simplify managing multiple asynchronous operations. The code creates callback actions that, when executed by the asynchronous operation, track which asynchronous methods ...
2
votes
1answer
43 views

JavaScript and callback: apply an action on each element of a callback input

I'm quite new to js. I even don't know how to call this problem: apply an action on each element of a callback input, but the elements are actually an output.. I crash a lot on this situation: I have ...
1
vote
1answer
57 views

Is this a proper callback implementation in Java?

I have a code which I believe is callback implementation. Can you please provide your more experienced opinions on whether this is a good way to ...
6
votes
1answer
613 views

MVC Model validation callback

I have made a simple MVC framework of my own for my personal website to learn a thing or two about how this whole thing even works. I think I've got the idea, but there's one thing I'm not sure about. ...