Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
6k 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
121 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
2k 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
62 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
57 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
76 views

Type determined return values

I have the following js code: ...
2
votes
1answer
1k 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
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 ...
2
votes
1answer
122 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
380 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
420 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
52 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
75 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
943 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. ...
3
votes
1answer
491 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 ...
4
votes
1answer
186 views

A method for events callback with the correct “this”

What do you think of the following "utility" : ...
2
votes
1answer
748 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 ...
3
votes
2answers
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 ...
3
votes
1answer
541 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 ...
2
votes
1answer
170 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. ...
2
votes
2answers
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: ...
7
votes
2answers
19k 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 ...
12
votes
1answer
374 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 ...
4
votes
2answers
13k 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 ...
6
votes
4answers
389 views

Identify Java Callback

I have this common design in my application: ...
6
votes
2answers
69 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: ...
7
votes
1answer
124 views

Requesting Resources Until Exhaustion

When an API has a 'next' feature, I use the following pattern to obtain all the results: ...
3
votes
1answer
168 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 ...
4
votes
0answers
901 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: ...
6
votes
1answer
1k 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 ...
2
votes
2answers
170 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 ...
6
votes
2answers
189 views

Is this the right way to work with callbacks and the EventEmitter?

I'm creating a small online multiplayer game in NodeJS and I'm wondering if I'm "doing it right". Here is a bit of my code: ...
3
votes
1answer
2k views

Node.js async callback hell

I'm attempting to create a final array with data pulled from 3 functions. The first two functions have all the data but then the 3rd function needs to run looping through one of the fields from ...
5
votes
1answer
719 views

Python model for a “snake”-like game

I wrote a python model for the game "snake" that I'm not really satisfied with. My intention was to separate the game logic from the drawing and input handling (which worked quite well) but I've got ...
1
vote
1answer
7k views

Node.js DynamoDB callback

I am writing an API which gets results from a DynamoDB table and puts the JSON back into the browser. The code below works and returns the desired results. However, after reading about async and ...
2
votes
3answers
29k views

Time of day based timer - run function at certain time, daily

I need to call a function exactly at certain hour, daily, my programs runs 24/7. I wrote the following timer mechanism, which generally works that way: Calculate time until hour and generate timer ...
4
votes
1answer
2k views

Fast templated call back implementation

Below is the code for my templated callback implementation. Currently it works for a single parameter. One thing I was going to try and do next was increase the argument to the function from 1..N ...
2
votes
1answer
92 views

My yld NPM - callbacks/promises alternative

I'd like feedback on my callbacks/promises alternative, please. The yld repository ...
3
votes
1answer
3k views

Javascript Queue for async functions

Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually ...
6
votes
1answer
152 views

replaceWithCallback() UDF

As explained in my blog article… I was looking up the docs for Javascript's String replace() function the other day (because, no, I could not remember the vagaries of its syntax!). And whilst ...
7
votes
1answer
461 views

Prime Numbers Store

Let's say we need to create a store for selling prime numbers. Users enter the store and ask to buy a number. If the number asked is a prime number, 1.1. then it's either available for sale 1.2. ...
1
vote
1answer
192 views

Callback for job applicant

This is on a job listing site and it has a Linkedin apply button plugin - this provides for a callback the someone has applied for a job. I've written the callback function which extracts the Job ID (...
3
votes
2answers
776 views

Passing Context in CoffeeScript

I'm trying to migrate from JavaScript to CoffeeScript. However I'm not sure about the best way to optimize the code generated by js2coffee. Below is the original JavaScript source : ...
4
votes
1answer
3k views

Collection of Actions

I am trying to create a class to queue up a series of commands. (Not really a queue as events happen based on time). Each command has a callback (Action) that get's called. However, each Action has a ...
1
vote
1answer
9k views

Calling a function when all asynchronous calls complete [closed]

Below is a simplified version of some code I am using to execute a function after all asynchronous calls complete. Is this a reasonable piece of code? It seems to work. Nothing would break if ...
1
vote
1answer
540 views

Update subscription

First, some background. I have a Payment model that has_many :subscriptions. When a user pays (creates a new payment), I have an ...
6
votes
1answer
6k views

Node.js callback error pattern

The errors are passed through every callback, but in fact, it might be better to throw an error at higher levels. For example, look at the mongodb.js database function. It passes through an error in ...
2
votes
2answers
135 views

Allowing messages to be passed to listeners [closed]

I have written an implementation of the observer pattern that allows messages to be passed to listeners in what would normally be the notify() method. For example a ...
3
votes
1answer
2k views

Basic socket library in C

I am trying to learn C and have written a very basic socket library. I would be interested in any general design and coding comments. Note that at this stage I am not bothered about implementing the ...
4
votes
1answer
747 views

“Piping” from a callback to an Iterator

My project has a central concept of a Callback<T> which is defined very simply: ...