-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from supertokens/pre-release-1.2.3
Pre release 1.2.3
- Loading branch information
Showing
10 changed files
with
165 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import SuperTokensLock from "./index"; | ||
declare var getNewInstance: () => SuperTokensLock; | ||
export { getNewInstance }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
export default class Lock { | ||
acquireLock: (lockKey: string, timeout?: number) => Promise<boolean> | ||
releaseLock: (lockKey: string) => void | ||
} | ||
export default class SuperTokensLock { | ||
private static waiters; | ||
private id; | ||
private acquiredIatSet; | ||
constructor(); | ||
/** | ||
* @async | ||
* @memberOf Lock | ||
* @function acquireLock | ||
* @param {string} lockKey - Key for which the lock is being acquired | ||
* @param {number} [timeout=5000] - Maximum time for which the function will wait to acquire the lock | ||
* @returns {Promise<boolean>} | ||
* @description Will return true if lock is being acquired, else false. | ||
* Also the lock can be acquired for maximum 10 secs | ||
*/ | ||
acquireLock(lockKey: string, timeout?: number): Promise<boolean>; | ||
private refreshLockWhileAcquired; | ||
private waitForSomethingToChange; | ||
private static addToWaiting; | ||
private static removeFromWaiting; | ||
private static notifyWaiters; | ||
/** | ||
* @function releaseLock | ||
* @memberOf Lock | ||
* @param {string} lockKey - Key for which lock is being released | ||
* @returns {void} | ||
* @description Release a lock. | ||
*/ | ||
releaseLock(lockKey: string): Promise<void>; | ||
/** | ||
* @function releaseLock | ||
* @memberOf Lock | ||
* @param {string} lockKey - Key for which lock is being released | ||
* @returns {void} | ||
* @description Release a lock. | ||
*/ | ||
private releaseLock__private__; | ||
/** | ||
* @function lockCorrector | ||
* @returns {void} | ||
* @description If a lock is acquired by a tab and the tab is closed before the lock is | ||
* released, this function will release those locks | ||
*/ | ||
private static lockCorrector; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.