Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

KnottySoft/knotty-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KNOTTY-LOCK

Description

Lock system for asynchronous requests (ex: Ajax)

Why a lock?

Was discussing an issue with a work colleague where an ajax request would be executed multiple times because the triggered control existed multiple times in the DOM. We found a work around prior to writing this plugin, but this simplifies the whole problem by stopping the call dead in it's tracks after it has been called once and only allows it to be called again once it has be released.

How does it work?

First, link the knotty-lock.js file in your page or as a package in node.js. Once that's done, it's as simple as englobing the lock around your request, and unlocking the element once the request is complete (success, error, etc.)

###To lock:

if (knottyLock.add(keyOfYourChoosing)) { //ajax request here } 

###To unlock

 knottyLock.remove(keyOfYourChoosing); /* once request is complete (success, erroc, etc.) */

View the example for a better overview of how it works

About

Lock system for asynchronous commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published