1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

feat: improve async actions docs and guards (#4215)

* docs: clarify submit handler in standalone example

* docs: clarify protection against re-running actions

* docs: clarify that these directives replace click and ngSubmit

* docs: clarify `void`

* feat: disable action directive on bitsubmit disable

* docs: fix grammar

* docs: change to note

* feat: guard against double running bitAction
This commit is contained in:
Andreas Coroiu
2022-12-14 08:47:01 +01:00
committed by GitHub
parent b16d7a6f6e
commit 3ffeb684a7
4 changed files with 38 additions and 24 deletions

View File

@@ -18,6 +18,8 @@ export class BitActionDirective implements OnDestroy {
private destroy$ = new Subject<void>();
private _loading$ = new BehaviorSubject<boolean>(false);
disabled = false;
@Input("bitAction") protected handler: FunctionReturningAwaitable;
readonly loading$ = this._loading$.asObservable();
@@ -39,7 +41,7 @@ export class BitActionDirective implements OnDestroy {
@HostListener("click")
protected async onClick() {
if (!this.handler) {
if (!this.handler || this.loading || this.disabled || this.buttonComponent.disabled) {
return;
}