Skip to content

nativeScriptBootstrap should probably return a promise #156

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

Closed
matt4446 opened this issue Apr 4, 2016 · 6 comments
Closed

nativeScriptBootstrap should probably return a promise #156

matt4446 opened this issue Apr 4, 2016 · 6 comments

Comments

@matt4446
Copy link

matt4446 commented Apr 4, 2016

Angular 2 bootstrap - returns Promise<ComponentRef>

NativeScript's Angular2 bootstrap implementation - returns Promise<ComponentRef>

NativeScript's nativeScriptBootstrap implementation returns void.

I expect the sample projects and documentation will continue to prefer the nativeScriptBootstrap function to start the application. What I believe to be missing from nativeScriptBootstrap is that it should return a Promise<ComponentRef> just as the bootstrap method does, which will make the following possible and add flexibility if needed:

nativeScriptBootstrap(startComponent).then((appRef : ComponentRef) => {});

@battistaar
Copy link

I'm trying to use the promise, but it seems that it is never called.

nativeScriptBootstrap(AppComponent).then(function(appRef: ComponentRef<AppComponent>){ console.log("done!"); });

The console prints "ANGULAR BOOTSTRAP DONE." and nothing else.

@matt4446
Copy link
Author

matt4446 commented May 20, 2016

@battistaar I'm pretty sure it works as I use it here. Which version of nativescript-angular are you using?

I'll double check this evening to make sure.

@battistaar
Copy link

0.1.6
I checked the source code of the package and it should return a promise and resolve it with the app ref, but it doesn't.

I'm not sure that's the problem, but according to the documentation "Any code after the start call will not be executed.". nativeScriptBootstrap calls application.start and it seems that everything I write after is not executed, either inside or outside the "then".

@matt4446
Copy link
Author

Curious. Lucky I never read the documentation. That just raises more questions. Are you running it on IOS? I have not tried it there.

I didn't escape work till just over an hour ago ... and so my response is much later than expected.

Android:

JS: Setup App annotations
JS: Page loaded
JS: BOOTSTRAPPING...
JS: Setting DOM
JS: =Debug===============
JS: 2016-05-20T21:49:46.510Z: Main Page Starting
JS: ======================
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ANGULAR BOOTSTRAP DONE.
JS: Add element: CardView
JS: Add element: PullToRefresh
JS: =Debug===============
JS: 2016-05-20T21:49:46.843Z: Start Page - constructor hit
JS: ======================

Two console writes after the app promise:

JS: Add element: CardView
JS: Add element: PullToRefresh

It is the only place I have Add element. ;-)

subscribing to the promise on the sample app I presume you end up with the same result? (from the nativescript samples http://docs.nativescript.org/angular/tutorial/ng-chapter-1)

@battistaar
Copy link

I did some tests and it seems that it's an iOS related problem, it works on android emulator

@matt4446
Copy link
Author

I would create a new issue and copy this one in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants