coturiv / ionic-typeorm-starter

Example project to demonstrate TypeORM in an Ionic app
32 stars 12 forks source link

Hotfix: Changes to the async initialization sequence, #5

Open StephaneSeyvoz opened 5 years ago

StephaneSeyvoz commented 5 years ago

Hotfix: Changes to the async initialization sequence

Checked using Ionic 5.4.4 and Cordova 9.0.0 installed globally, deploying on an Android 9 (API level 28) emulator and an Android 7 device, both in 'dev' and 'prod' profiles.

This solves the

'ERROR …Error: Uncaught (in promise): RepositoryNotFoundError: No repository for "post" was found. Looks like this entity is not registered in current default connection?'

error, happening because the getRepository('post') call in home.page would happen before the TypeORM connection created by the db.service was ready, despite trying to wait for its initialization in app.component.

This is of course just a suggestion of correction, feel free to adapt as you wish.