Questions tagged [promise]
"Promises" are a particular tactic for deferred computing, suitable for several styles of concurrency: thread and event loop concurrency for local computation, and both synchronous and asynchronous remote messaging.
250 questions
6
votes
2
answers
311
views
Timezone-based VPN-detection
I use the following snippet with my browser homepage to detect whether or not I have my VPN connection turned on. If the IP timezone is different from the browser timezone, then it is most likely the ...
4
votes
1
answer
109
views
A class that will manage a thread and execute tasks (e.g., SQL queries) within it
I am interested in creating a class that manages a thread and executes SQL queries sequentially within it. The queries would be submitted from various parts of the program, and the results would be ...
1
vote
1
answer
111
views
Axios wrapper used with API requests
I have created Axios wrapper following SOLID principles. Is there any feedback on improving it's structure in a more cleaner and better way?
axiosconfig.ts
...
4
votes
2
answers
439
views
Full Promise implementation
I have attempted to implement the native Promise object provided by the browser in JavaScript. The code is pretty easy to understand. It supports most of the promise functionalities, such as chaining, ...
14
votes
2
answers
47k
views
Using async / await with dynamic import() for ES6 modules
I am experimenting with the best way to standardise my dynamic import() expressions when importing javascript modules.
import() ...
0
votes
1
answer
118
views
Handling pure in browser HTTP request in Service Worker fetch event
I was suggested by @Bergi on StackOverflow that Async Promise constructors are any pattern.
The argument behind this is that async Promise swallows the errors. In my case, I have try..catch so I'm not ...
4
votes
2
answers
165
views
Idempotent JavaScript script loader
I wrote an idempotent script loader (for the browser), where the same script won't be loaded more than once.
scriptLoader.js:
...
8
votes
3
answers
4k
views
await user input with async/await syntax
for clarity: moved here from stackoverflow after being pointed to Code Review being the better place for this question
I love async/await and Promises since I got my hands on them. And I might be ...
10
votes
2
answers
24k
views
Check if images are loaded (ES6 Promises)
I wrote a small function that checks if an image or multiple images are loaded. For that purpose, I decided to use ES6 promises, but I'm not really sure if my way of handling errors is the best way.
<...
10
votes
2
answers
571
views
Stack Exchange review queue notifications
A couple of days ago a user in chat asked us to spend more time in the queues. Kick starting my desire to get notifications for new items in the queues.
Reviewing the queues has been something I've ...
1
vote
1
answer
453
views
React Native login, sign up and sign out using Firebase project
I have built a basic app which uses firebase for authentication.
The app is pretty simple.
Sign up the user to firebase using email and password.
Sign in the user
Sign out the user
Also, I have ...
4
votes
1
answer
1k
views
Wrap async method in a way that the method is invoked only once for all calls that occur while the first of them is not resolved
Imagine we have a function that returns a Promise, ie call a GET endpoint of an api and return the response data.
...
2
votes
0
answers
316
views
JavaScript proxy for better stack traces from external libraries
I've been using the excellent pg-promise library for a few years now, but my primary irk with it is that the stack traces are sometimes unhelpful. For example, the following test will fail (currently ...
1
vote
1
answer
2k
views
NodeJS promise loop through all files in directory
I am trying to re-organise my mp3 collection based on its id3 meta data into folders based on the artist. I'm new to nodeJs and more importantly promises. I was hoping I could get some feedback on my ...
2
votes
1
answer
138
views
Basic node login routes for authentication system
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
...