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)
1
vote
1answer
40 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.
...
1
vote
0answers
43 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:
...
3
votes
2answers
48 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 ...
10
votes
2answers
131 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 ...
1
vote
0answers
58 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
274 views
6
votes
2answers
59 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
115 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
54 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 ...
3
votes
0answers
202 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:
...
2
votes
2answers
73 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
76 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
124 views
Using Callback in Codenameone native code using Java [closed]
I would like to use Callbacks in my StateMachine to fetch values from Callback class, that is set in the native Android code.
Is this a right approach to create one? Do you see any issues with the ...
3
votes
1answer
658 views
Node.js Async Callback Hell
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 function 2 ...
4
votes
1answer
91 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
518 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 ...
0
votes
2answers
3k 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 ...
2
votes
2answers
154 views
Please review my 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 ...
0
votes
0answers
52 views
My yld NPM - callbacks/promises alternative
I'd like feedback on my callbacks/promises alternative, please.
The yld repository
...
0
votes
1answer
363 views
Best practice on implementing Java Swing Callback
I guess I am at the design stage and as such dont have actual code to review so this might be the wrong place to ask this in which case let me know and happy to close/move the question
I am trying to ...
1
vote
0answers
758 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 ...
7
votes
1answer
216 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
107 views
my first jquery/json
This is my first use of jquery and json so would be grateful for any feedback please.
Background - this is on a job listing site and it has a Linkedin apply button plugin - this provides for a ...
3
votes
2answers
249 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
208 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
546 views
Calling a function when all asynchronous calls complete
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
301 views
Improve on an after_create callback with database queries - Ruby on Rails
First, some background. I have a Payment model that has_many :subscriptions. When a user pays (creates a new payment), I have an ...
1
vote
1answer
425 views
How to fix retrieval of receive data - very basic socket library in C
I am trying to learn C and have written a very basic socket library listed below. I would be interested in any general design and coding comments.
Note that at this stage I am not bothered about ...
3
votes
1answer
290 views
“Piping” from a callback to an Iterator
My project has a central concept of a Callback<T> which is defined very simply:
...
2
votes
2answers
155 views
Ruby Callback System
Version 1
I need a way to store and retrieve callbacks in Ruby. So I made a Callbacks class. Any suggestions would be greatly appreciated, thank you!
...
0
votes
1answer
2k 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 ...
25
votes
2answers
2k 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 ...
2
votes
1answer
143 views
jQuery callbacks optimization
I have a lot of repeatable blocks of code and want to optimize/simplify them:
...
6
votes
1answer
232 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 ...