blockers
This commit is contained in:
22
apps/website/lib/blockers/SubmitBlocker.ts
Normal file
22
apps/website/lib/blockers/SubmitBlocker.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Blocker } from './Blocker';
|
||||
|
||||
/**
|
||||
* SubmitBlocker prevents multiple submissions until explicitly released.
|
||||
*
|
||||
* Useful for preventing duplicate form submissions or API calls.
|
||||
*/
|
||||
export class SubmitBlocker extends Blocker {
|
||||
private blocked = false;
|
||||
|
||||
canExecute(): boolean {
|
||||
return !this.blocked;
|
||||
}
|
||||
|
||||
block(): void {
|
||||
this.blocked = true;
|
||||
}
|
||||
|
||||
release(): void {
|
||||
this.blocked = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user