@matchlighter/common_library
Advanced tools
Comparing version
@@ -25,13 +25,22 @@ /** | ||
private paused; | ||
/** The most recently completed transaction number */ | ||
private currentState; | ||
/** The most recently queued transaction number */ | ||
private wantedState; | ||
/** The most recently started transaction number */ | ||
private requestedState; | ||
get isCaughtUp(): boolean; | ||
get isExecuting(): boolean; | ||
queueRefresh(skip_debounce?: boolean): void; | ||
forceRefreshNow(): void; | ||
/** Mark the Transactor as dirty and schedule a transaction to be performed */ | ||
performSoon(skip_debounce?: boolean): void; | ||
/** Mark the Transactor as dirty and perform a transaction immediately */ | ||
performNow(): void; | ||
/** Immediately perform a transaction if the Transactor is dirty */ | ||
performNowIfNeeded(): void; | ||
/** Mark the Transactor as clean, cancelling any pending transactions */ | ||
markCaughtUp(): void; | ||
/** Prevent the Transactor from starting any transactions (started transactions will continue) */ | ||
pause(): void; | ||
/** Un-pause the Transactor. Will queue a transaction if dirty */ | ||
resume(immediate?: boolean): void; | ||
pause(): void; | ||
private caughtupPromise; | ||
@@ -38,0 +47,0 @@ private tokenPromises; |
@@ -21,4 +21,7 @@ "use strict"; | ||
this.paused = false; | ||
/** The most recently completed transaction number */ | ||
this.currentState = 0; | ||
/** The most recently queued transaction number */ | ||
this.wantedState = 0; | ||
/** The most recently started transaction number */ | ||
this.requestedState = 0; | ||
@@ -49,3 +52,4 @@ this.tokenPromises = {}; | ||
} | ||
queueRefresh(skip_debounce = false) { | ||
/** Mark the Transactor as dirty and schedule a transaction to be performed */ | ||
performSoon(skip_debounce = false) { | ||
this.wantedState++; | ||
@@ -62,3 +66,4 @@ if (this.paused) | ||
} | ||
forceRefreshNow() { | ||
/** Mark the Transactor as dirty and perform a transaction immediately */ | ||
performNow() { | ||
this.wantedState++; | ||
@@ -69,2 +74,3 @@ cancel_limit(this._performThrottledAndDebounced); | ||
} | ||
/** Immediately perform a transaction if the Transactor is dirty */ | ||
performNowIfNeeded() { | ||
@@ -77,2 +83,3 @@ if (!this.isCaughtUp) { | ||
} | ||
/** Mark the Transactor as clean, cancelling any pending transactions */ | ||
markCaughtUp() { | ||
@@ -85,4 +92,10 @@ this.currentState = this.wantedState; | ||
} | ||
/** Prevent the Transactor from starting any transactions (started transactions will continue) */ | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
/** Un-pause the Transactor. Will queue a transaction if dirty */ | ||
resume(immediate = false) { | ||
// Should we trigger on first resume? | ||
this.paused = false; | ||
@@ -98,7 +111,2 @@ if (!this.isCaughtUp) { | ||
} | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
resolveTokenPromises() { | ||
@@ -105,0 +113,0 @@ for (let { token, promise } of Object.values(this.tokenPromises)) { |
@@ -25,13 +25,22 @@ /** | ||
private paused; | ||
/** The most recently completed transaction number */ | ||
private currentState; | ||
/** The most recently queued transaction number */ | ||
private wantedState; | ||
/** The most recently started transaction number */ | ||
private requestedState; | ||
get isCaughtUp(): boolean; | ||
get isExecuting(): boolean; | ||
queueRefresh(skip_debounce?: boolean): void; | ||
forceRefreshNow(): void; | ||
/** Mark the Transactor as dirty and schedule a transaction to be performed */ | ||
performSoon(skip_debounce?: boolean): void; | ||
/** Mark the Transactor as dirty and perform a transaction immediately */ | ||
performNow(): void; | ||
/** Immediately perform a transaction if the Transactor is dirty */ | ||
performNowIfNeeded(): void; | ||
/** Mark the Transactor as clean, cancelling any pending transactions */ | ||
markCaughtUp(): void; | ||
/** Prevent the Transactor from starting any transactions (started transactions will continue) */ | ||
pause(): void; | ||
/** Un-pause the Transactor. Will queue a transaction if dirty */ | ||
resume(immediate?: boolean): void; | ||
pause(): void; | ||
private caughtupPromise; | ||
@@ -38,0 +47,0 @@ private tokenPromises; |
@@ -18,4 +18,7 @@ import { debounce, throttle } from "../limit"; | ||
this.paused = false; | ||
/** The most recently completed transaction number */ | ||
this.currentState = 0; | ||
/** The most recently queued transaction number */ | ||
this.wantedState = 0; | ||
/** The most recently started transaction number */ | ||
this.requestedState = 0; | ||
@@ -49,3 +52,4 @@ this.tokenPromises = {}; | ||
} | ||
queueRefresh(skip_debounce = false) { | ||
/** Mark the Transactor as dirty and schedule a transaction to be performed */ | ||
performSoon(skip_debounce = false) { | ||
this.wantedState++; | ||
@@ -62,3 +66,4 @@ if (this.paused) | ||
} | ||
forceRefreshNow() { | ||
/** Mark the Transactor as dirty and perform a transaction immediately */ | ||
performNow() { | ||
this.wantedState++; | ||
@@ -69,2 +74,3 @@ cancel_limit(this._performThrottledAndDebounced); | ||
} | ||
/** Immediately perform a transaction if the Transactor is dirty */ | ||
performNowIfNeeded() { | ||
@@ -77,2 +83,3 @@ if (!this.isCaughtUp) { | ||
} | ||
/** Mark the Transactor as clean, cancelling any pending transactions */ | ||
markCaughtUp() { | ||
@@ -85,4 +92,10 @@ this.currentState = this.wantedState; | ||
} | ||
/** Prevent the Transactor from starting any transactions (started transactions will continue) */ | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
/** Un-pause the Transactor. Will queue a transaction if dirty */ | ||
resume(immediate = false) { | ||
// Should we trigger on first resume? | ||
this.paused = false; | ||
@@ -98,7 +111,2 @@ if (!this.isCaughtUp) { | ||
} | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
resolveTokenPromises() { | ||
@@ -105,0 +113,0 @@ for (let { token, promise } of Object.values(this.tokenPromises)) { |
{ | ||
"name": "@matchlighter/common_library", | ||
"version": "1.6.8", | ||
"version": "1.6.9", | ||
"description": "Shared Functions, Helpers, Patterns & Utilities for Apps and Libraries", | ||
@@ -5,0 +5,0 @@ "author": "Matchlighter", |
@@ -51,4 +51,7 @@ import { debounce, throttle } from "../limit"; | ||
/** The most recently completed transaction number */ | ||
private currentState = 0; | ||
/** The most recently queued transaction number */ | ||
private wantedState = 0; | ||
/** The most recently started transaction number */ | ||
private requestedState = 0; | ||
@@ -64,3 +67,4 @@ | ||
queueRefresh(skip_debounce = false) { | ||
/** Mark the Transactor as dirty and schedule a transaction to be performed */ | ||
performSoon(skip_debounce = false) { | ||
this.wantedState++; | ||
@@ -78,3 +82,4 @@ | ||
forceRefreshNow() { | ||
/** Mark the Transactor as dirty and perform a transaction immediately */ | ||
performNow() { | ||
this.wantedState++; | ||
@@ -86,2 +91,3 @@ cancel_limit(this._performThrottledAndDebounced); | ||
/** Immediately perform a transaction if the Transactor is dirty */ | ||
performNowIfNeeded() { | ||
@@ -95,2 +101,3 @@ if (!this.isCaughtUp) { | ||
/** Mark the Transactor as clean, cancelling any pending transactions */ | ||
markCaughtUp() { | ||
@@ -104,4 +111,11 @@ this.currentState = this.wantedState; | ||
/** Prevent the Transactor from starting any transactions (started transactions will continue) */ | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
/** Un-pause the Transactor. Will queue a transaction if dirty */ | ||
resume(immediate = false) { | ||
// Should we trigger on first resume? | ||
this.paused = false; | ||
@@ -118,8 +132,2 @@ | ||
pause() { | ||
this.paused = true; | ||
cancel_limit(this._performThrottledAndDebounced); | ||
cancel_limit(this._performThrottled); | ||
} | ||
private caughtupPromise: ControlledPromise<any>; | ||
@@ -166,3 +174,2 @@ private tokenPromises: Record<number, { token: number, promise: ControlledPromise<any> }> = {}; | ||
private async performTransaction() { | ||
@@ -169,0 +176,0 @@ if (this.paused) return; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
622747
0.54%10929
0.39%