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
1 answer
47 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 ...
mattNit's user avatar
  • 33
3 votes
0 answers
1k 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 ...
shane's user avatar
  • 171
2 votes
1 answer
36 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 ...
PascalVKooten's user avatar
4 votes
1 answer
4k 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 ...
HeuHeu's user avatar
  • 59
11 votes
1 answer
2k 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-...
Crossfire's user avatar
  • 211
4 votes
2 answers
1k views

C++ EventHandler class, invoking & arguments

This is my EventHandler class, which is extremely simple and can be used on lambdas and similar: ...
Yamiez's user avatar
  • 41
6 votes
1 answer
236 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. ...
52d6c6af's user avatar
  • 672
2 votes
1 answer
144 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: ...
Jonathan Solorzano's user avatar
1 vote
1 answer
163 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 ...
Amanda Ferrari's user avatar
5 votes
1 answer
91 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 ...
Maurício D'Angelo Fernandes's user avatar
11 votes
1 answer
2k 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 ...
m.g.'s user avatar
  • 111
1 vote
1 answer
111 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. ...
Taylorsuk's user avatar
  • 261
21 votes
2 answers
15k 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. ...
AntoineB's user avatar
  • 313
3 votes
1 answer
3k views

Python lazy dictionary

Here is a lazy dictionary with test cases. ...
Justin Fay's user avatar
5 votes
1 answer
588 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 ...
W.K.S's user avatar
  • 512
2 votes
1 answer
497 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 ...
program247365's user avatar
5 votes
2 answers
3k 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 ...
CoderMusgrove's user avatar
4 votes
4 answers
92 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 ...
Ricky Wilson's user avatar
  • 1,695
2 votes
1 answer
238 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 ...
JBCP's user avatar
  • 129
10 votes
2 answers
6k views

C-ifying a capturing lambda

What do you think of this code? ...
user1095108's user avatar
  • 1,414
3 votes
1 answer
7k 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 ...
rnrneverdies's user avatar
6 votes
1 answer
3k 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 ...
GregB's user avatar
  • 163
5 votes
1 answer
65 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 ...
oscar539's user avatar
2 votes
1 answer
59 views

The best way to place callback definition [closed]

In JavaScript we can write callback definition in many different ways: Definition after usage: ...
hellboy's user avatar
  • 155
1 vote
3 answers
81 views

Type determined return values

I have the following js code: ...
Dethariel's user avatar
  • 183
2 votes
1 answer
2k 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 ...
laggingreflex's user avatar
1 vote
1 answer
5k 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 ...
Matthew Green's user avatar
2 votes
1 answer
126 views

Observable storage - revised

Previous question: JavascriptObservable Storage The idea is to have some storage interface that exists of different buckets - known as Eagles: ...
Pinoniq's user avatar
  • 2,970
8 votes
2 answers
436 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 ...
Nick Udell's user avatar
  • 5,197
1 vote
1 answer
478 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 ...
Nick Udell's user avatar
  • 5,197
3 votes
1 answer
59 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 ...
nkint's user avatar
  • 518
1 vote
1 answer
80 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 ...
Alex's user avatar
  • 111
6 votes
1 answer
1k 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. ...
user2374794's user avatar
3 votes
1 answer
787 views

Notify Property Changed

Inspired by a SO post, just as an exercise, I tried to implement a way of notifying a consumer of a class about whether a property on an object has changed or not. I'm not attempting to use this in ...
tbddeveloper's user avatar
4 votes
1 answer
190 views

A method for events callback with the correct "this"

What do you think of the following "utility" : ...
Julien CROUZET's user avatar
2 votes
1 answer
809 views

Module pattern callback implementation

I'm rewriting a simple app using HTML/CSS/JavaScript that creates animations with images using intervals, and there's a bunch of buttons that controls these animations. It's scaling and becoming ...
zok's user avatar
  • 213
3 votes
2 answers
3k views

Load images, manipulate DOM, store/retrieve data using localStorage

I wrote a little code sample which: load images manipulate DOM (replace images) store/retrieve related data using localStorage ...
zok's user avatar
  • 213
3 votes
1 answer
714 views

Three implementations of observable objects

I wonder, what might be the best (most pythonic) way of implementing multiple observerables in Python. There are multiple objects, which should be able to register themselves at one or multiple ...
Sebastian Werk's user avatar
2 votes
1 answer
175 views

Can this code utilizing promises be written more succinctly?

I've written the following code to get all .txt files in a directory and read+delete them, repeating every 15 seconds. ...
XåpplI'-I0llwlg'I  -'s user avatar
2 votes
2 answers
1k views

JavaScript parameters - best practices for settings object/callback

I have the following function which runs as expected and is defined in the window object: ...
keldar's user avatar
  • 333
7 votes
2 answers
22k views

Callback on AlertDialog

I am using an AlertDialog in Android, asking the user for some input. I would like do run some code when the user has finished entering her input. Since an ...
JonasVautherin's user avatar
12 votes
1 answer
481 views

Pledge: Promise-like entities design goals experiment

Background I was writing a promises/a+ implementation, just for fun. About halfway through I decided it wasn't that fun after all, so I decided to do something a little different. Thinking of ...
Dagg's user avatar
  • 4,531
4 votes
2 answers
14k views

Generic callback object, but I need the type parameter inside methods

Inside my android app, I currently have methods that look like below code. Since they all need a callback object that basically does the same thing and I would like to try to eliminate the duplicated ...
nPn's user avatar
  • 165
7 votes
4 answers
436 views

Identify Java Callback

I have this common design in my application: ...
Pierre-Jean's user avatar
6 votes
2 answers
72 views

Alternate way for comparison call back function?

I'm doing a programming practice problem and was wondering if someone can suggest a better to create/setup the call back for the comparison function. I have the following classes: ...
user3379755's user avatar
7 votes
1 answer
132 views

Requesting Resources Until Exhaustion

When an API has a 'next' feature, I use the following pattern to obtain all the results: ...
Tanaki's user avatar
  • 173
3 votes
1 answer
175 views

Using jquery Callbacks.fire method as a event handler

So I've got a jquery project where I'm using an external class that has callback style events. Meaning, it has an "onSave" property that takes one function. However, I need to more than one other ...
Andy Smith's user avatar
4 votes
0 answers
935 views

Aysnc call back to UI Thread

My main DLL is a .Net one that has an async running method and fires an event when it's done: ...
JayTee's user avatar
  • 141
6 votes
1 answer
2k views

Hooking with Python3 Decorators

I wrote this prototype after reading the Wikipedia article on hooking. I didn't bother to read any of the code examples listed there because, well, I just didn't. I don't have a good excuse. The ...
user avatar
2 votes
2 answers
178 views

Conditional functions or multiple similar definitions?

In my program(C++), I'm going to use callback functions to process input from the keyboard and mouse and constantly draw a scene. How these functions process information will change depending on the ...
Hex4869's user avatar
  • 185