mutex-promise | A simple JS Mutex library that works both in browser | Runtime Evironment library
kandi X-RAY | mutex-promise Summary
kandi X-RAY | mutex-promise Summary
A simple JS Mutex library that works both in browser and NodeJS. Library ensures that asynchronous code will wait until the mutex is unlocked, even if it was locked from another tab. The usual use-case is when you need to do a server request and you’d like to make sure that only one concurrent request will be executed, others will wait until the mutex is unlocked, no matter which tab has created the request.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Mutex immutable Promise .
- Create a new mutex object
mutex-promise Key Features
mutex-promise Examples and Code Snippets
Community Discussions
Trending Discussions on mutex-promise
QUESTION
I am making a Javascript page that requests data on user events
A lot of data needs to be retrieved per event, so I get a small amount of the data with a single AJAX request so I can show updates. The callback recursively requests more data via AJAX until there's no data left to get. Within this "chain", everything goes well.
Problems, however, arise when an user fires more events when a different chain is already running. Both chains use the same data object, so data gets lost. What is the proper way to queue these user events so they don't run concurrently? I've added a mutex (https://github.com/kirill-konshin/mutex-promise) but that doesn't take into account the AJAX request.
General code structure:
...ANSWER
Answered 2020-Jun-17 at 15:39you can try using simply count check of number of times, the user trigger the event, pendingAjaxCount
will store the user event trigger, based on each trigger completion, it will helps to reduce the count and trigger the next ajax call
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mutex-promise
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page