Skip to main content

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
2 votes
3 answers
32k 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 ...
Ofiris's user avatar
  • 183
4 votes
1 answer
4k 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 ...
bjackfly's user avatar
  • 493
2 votes
1 answer
96 views

My yld NPM - callbacks/promises alternative

I'd like feedback on my callbacks/promises alternative, please. The yld repository ...
Lcf.vs's user avatar
  • 121
3 votes
1 answer
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 ...
Marcus Hughes's user avatar
6 votes
1 answer
166 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 ...
Adam Cameron's user avatar
7 votes
1 answer
509 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. ...
rycle's user avatar
  • 145
1 vote
1 answer
220 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 (...
user602088's user avatar
3 votes
2 answers
811 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 : ...
uyetch's user avatar
  • 133
4 votes
1 answer
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 ...
001's user avatar
  • 250
1 vote
1 answer
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 ...
Brian's user avatar
  • 548
1 vote
1 answer
543 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 ...
GorrillaMcD's user avatar
6 votes
1 answer
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 ...
onlineracoon's user avatar
2 votes
2 answers
138 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 ...
JeremyFromEarth's user avatar
3 votes
1 answer
3k 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 ...
arcomber's user avatar
  • 2,439
5 votes
1 answer
897 views

"Piping" from a callback to an Iterator

My project has a central concept of a Callback<T> which is defined very simply: ...
Steven Schlansker's user avatar
3 votes
1 answer
273 views

Ruby Callback System

I need a way to store and retrieve callbacks in Ruby, so I made a Callbacks class. Any suggestions would be greatly appreciated. ...
user avatar
3 votes
1 answer
5k views

Efficient implemetation of AlertDialog callback in Android

One day I realised that my Android project utilizes AlertDialogs here and there in very ineffective way. The heavily duplicated portion of code looked like this (actually, copied and pasted from some ...
Stan's user avatar
  • 211
5 votes
1 answer
6k views

Remove an event listener after firing once or any number of times

Remove an event listener after firing once or any number of times This is what I have: ...
XP1's user avatar
  • 151
36 votes
2 answers
6k views

Asynchronous network callback code

I did not get the job after submitting this piece of work in an interview, but I have no feedback to know what "BAD" things are inside this block of code. The requirements are: Connect to the ...
Kit Ho's user avatar
  • 491
3 votes
1 answer
172 views

jQuery callbacks optimization

I have a lot of repeatable blocks of code and want to optimize/simplify them: ...
350D's user avatar
  • 133
7 votes
1 answer
245 views

Do nothing lamda...

$privilegeStrings = array_filter($privileges, function ($s) { return is_string($s); } ); Is there a better way to specify that I want just the string values in ...
Billy ONeal's user avatar
  • 1,460

1 2 3
4