Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { createConnection } from 'typeorm';
import { DbService } from './services/db.service';


@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
Expand All @@ -17,7 +13,6 @@ export class AppComponent {
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private dbService: DbService
) {
this.initializeApp();
}
Expand All @@ -27,7 +22,5 @@ export class AppComponent {
this.statusBar.styleDefault();
this.splashScreen.hide();
});

await this.dbService.ready();
}
}
5 changes: 4 additions & 1 deletion src/app/pages/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getRepository, Repository } from 'typeorm';
import { Post } from 'src/app/entities/post';
import { Category } from 'src/app/entities/category';
import { Author } from 'src/app/entities/author';
import { DbService } from 'src/app/services/db.service';

@Component({
selector: 'app-home',
Expand All @@ -14,13 +15,15 @@ export class HomePage implements OnInit {
savedPost: boolean = false;
loadedPost: Post = null;

constructor() { }
constructor(private dbService: DbService) { }

ngOnInit() {
this.runDemo();
}

async runDemo() {
await this.dbService.ready();

const category1 = new Category();
category1.name = "TypeScript";

Expand Down
13 changes: 2 additions & 11 deletions src/app/services/db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,8 @@ export class DbService {
constructor(private platform: Platform) { }

async ready() {
try {

await getConnection();

} catch (ex) {

// console.log('Connection not established!', ex);

await this.createConnection();

}
await this.platform.ready();
await this.createConnection();
}

private createConnection(): Promise<Connection> {
Expand Down