Skip to content

Show/Hide without promise #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tomerpeled opened this issue Jul 2, 2017 · 4 comments
Open

Show/Hide without promise #71

tomerpeled opened this issue Jul 2, 2017 · 4 comments

Comments

@tomerpeled
Copy link

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?

@LaloHao
Copy link

LaloHao commented Jul 20, 2017

I'm interested in this aswell

@Pennywise83
Copy link

up

@Sn0oze
Copy link

Sn0oze commented Aug 17, 2017

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;
}

@Barryrowe
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants