From b739dd87cfce9f9158c9a81ca723fd8d5dc68d25 Mon Sep 17 00:00:00 2001 From: Julian Alimin Date: Sat, 15 Jul 2017 08:23:35 +0700 Subject: [PATCH 1/2] add platform is cordova check for ionic serve / browser usage --- src/providers/image-loader.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/providers/image-loader.ts b/src/providers/image-loader.ts index b94c151..1ae5031 100644 --- a/src/providers/image-loader.ts +++ b/src/providers/image-loader.ts @@ -78,16 +78,25 @@ export class ImageLoader { private fileTransfer: FileTransfer, private platform: Platform ) { - Observable.fromEvent(document, 'deviceready').first().subscribe(res => { - if (this.nativeAvailable) { - this.initCache(); - } else { + platform.ready().then(() => { + if (!platform.is('cordova')) { // we are running on a browser, or using livereload // plugin will not function in this case - this.isInit = true; + this.init = true; this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); + } else { + Observable.fromEvent(document, 'deviceready').first().subscribe(res => { + if (this.nativeAvailable) { + this.initCache(); + } else { + // we are running on a browser, or using livereload + // plugin will not function in this case + this.isInit = true; + this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); + } + }) } - }) + }); } /** From b452d29b9dbe9d6fb3649ada86f1fe6f3e3fa4af Mon Sep 17 00:00:00 2001 From: Julian Alimin Date: Sun, 16 Jul 2017 01:19:41 +0700 Subject: [PATCH 2/2] fix init to isInit --- src/providers/image-loader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/image-loader.ts b/src/providers/image-loader.ts index 1ae5031..7a5abd3 100644 --- a/src/providers/image-loader.ts +++ b/src/providers/image-loader.ts @@ -82,7 +82,7 @@ export class ImageLoader { if (!platform.is('cordova')) { // we are running on a browser, or using livereload // plugin will not function in this case - this.init = true; + this.isInit = true; this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); } else { Observable.fromEvent(document, 'deviceready').first().subscribe(res => {