Skip to content
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

add platform is cordova check for ionic serve / browser usage #78

Merged
merged 2 commits into from
Jul 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/providers/image-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.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.');
}
})
}
})
});
}

/**
Expand Down