akserg / ng2-slim-loading-bar

Angular 2 component shows slim loading bar at the top of the page.
MIT License
359 stars 92 forks source link

Complete callback passed to start method doesn't work #22

Open g-serghei opened 8 years ago

g-serghei commented 8 years ago

When using this construction:

this.loadingBar.start(() => {
    console.log('completed');
});

the complete callback is not called, it seems that you did not implemented it in your source code

start(onCompleted:Function = null) {
    // Stop current timer
    this.stop();
    // Make it visible for sure
    this.visible = true;
    // Run the timer with milliseconds iterval
    this._intervalCounterId = setInterval(() => {
        // Increment the progress and update view component
        this.progress++;
        // If the progress is 100% - call complete
        if (this.progress === 100) {
            this.complete();
        }
    }, this.interval);
}
niyazhussain commented 8 years ago

This is not done yet , i too had the same problem. But in my case i dont want to do anything after that , perhaps you can include an EventEmitter in his code.

akserg commented 8 years ago

Thanks all I think it would be better to return the Promise as a result of this file. Will fix it soon.

theoomoregbee commented 7 years ago

no update yet on this issue

theoomoregbee commented 7 years ago

gotten a way around it, subscribed to thethis._loadingBar.events.subscribe(item => console.log(item)); then if it is of progress we can check the percentage and then check if it is 100% or not