angular2-busy icon indicating copy to clipboard operation
angular2-busy copied to clipboard

Show/Hide without promise

Open tomerpeled opened this issue 7 years ago • 4 comments

Is there a simple way to show/hide the loading component without assigning it to a promise? I mean just by Showing/Hiding it directly via a component?

tomerpeled avatar Jul 02 '17 07:07 tomerpeled

I'm interested in this aswell

LaloHao avatar Jul 20 '17 20:07 LaloHao

up

Pennywise83 avatar Aug 04 '17 09:08 Pennywise83

You can just assign a boolean variable without using promises or observables in order to manually display the overlay.

[ngBusy]="{busy: showBusy, message: 'Loading...', backdrop: true, delay: 0, minDuration: 1000}"

ngOnInit() { this.showBusy= false; }

And just display it manually.

someMethod() { this.showBusy = true; // Do something this.showBusy = false; }

Sn0oze avatar Aug 17 '17 15:08 Sn0oze

@Sn0oze I don't know if we just never tried it because the docs say Promise or Observable<>, or a change since before we started using it allowed it, but this is exactly how we wanted to use the library.

before we had this awkward:

private startBusyWatch(msg: string): void {
        this.busyMessage = msg;
        this.busy = this.store.select(fromRoot.getApprovalsLoading)
             .filter((value) => value === false)
             .take(1)
             .subscribe();
    }

but looks like we can just use the async pipe like we want in our template now:

    [ngBusy]="{busy: (currentState$ | async).isLoading, message: busyMessage}"

and all we have to do is swap the component's busyMessage variable.

Barryrowe avatar Oct 02 '17 17:10 Barryrowe