Skip to content

Commit

Permalink
feat(loading): add postRequestError
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonornela committed Dec 1, 2016
1 parent 3981ae8 commit 9f1ab06
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/providers/loading-ionic.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@angular/core';
import { LoadingController } from 'ionic-angular';
import { PreRequestPlugin, PostRequestPlugin } from '@ramonornela/http';
import { LoadingController, Loading } from 'ionic-angular';
import { PreRequestPlugin, PostRequestPlugin, PostRequestErrorPlugin } from '@ramonornela/http';

@Injectable()
export class LoadingIonicPlugin implements PreRequestPlugin, PostRequestPlugin {
export class LoadingIonicPlugin implements PreRequestPlugin, PostRequestPlugin, PostRequestErrorPlugin {

protected loading;
protected loading: Loading = null;

protected allow: boolean = true;

Expand All @@ -32,8 +32,12 @@ export class LoadingIonicPlugin implements PreRequestPlugin, PostRequestPlugin {
}
}

postRequest() {
if (this.allow && this.loading) {
dismiss() {
if (this.loading === null) {
return;
}

if (this.allow) {
this.loading.dismiss();
}

Expand All @@ -48,6 +52,14 @@ export class LoadingIonicPlugin implements PreRequestPlugin, PostRequestPlugin {
}
}

postRequest() {
this.dismiss();
}

postRequestError() {
this.dismiss();
}

disableLoading(restore: boolean = false): this {
if (restore === true) {
this.allowPrevious = this.allow;
Expand All @@ -72,7 +84,7 @@ export class LoadingIonicPlugin implements PreRequestPlugin, PostRequestPlugin {
}

protected getLoading() {
if (!this.loading) {
if (this.loading === null) {
this.loading = this.loadingController.create(this.loadingOptions);
}

Expand Down

0 comments on commit 9f1ab06

Please sign in to comment.