You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
Cross-platform modules:
✔ Component nativescript has 5.0.0 version and is up to date.
✔ Component tns-core-modules has 5.0.2 version and is up to date.
✔ Component tns-android has 5.0.0 version and is up to date.
✔ Component tns-ios has 5.0.0 version and is up to date.
Android Runtime: 5.0.0
iOS Runtime: 5.0.0
Plugin(s): None
Node.js: 10.12.0
Please, attach your package.json and webpack.config.js as these configurations are usually critical for investigating issues with webpack.
These are default out of the box configs from using tns create
Describe the bug
When HMR tears down the Angular platform on changes, it correctly calls ngOnDestroy for all components etc, however it does not for services, meaning your app can end up in a weirdly initialized state with multiple "singletons" running side by side.
To Reproduce tns create - create a new angular project with say, the tabbed view.
Insert a constructor in app/core/data.service.ts: constructor() { console.log("DataService constructor"); } tns run android --hmr - the app starts, "DataService constructor" is written in console as expected.
Change some text in home.component.html that will cause a refresh. "DataService constructor" gets output again.
A lifecycle hook that is called when a directive, pipe, or service is destroyed.
You can imagine the trouble you can get in when you start including Rx Observable subscriptions in the constructor of a service, and even more when services start bootstrapping plugins.
So ngOnDestroy should also get called for services.
The text was updated successfully, but these errors were encountered:
@larssn hey - not sure if this is still relevant for you: I just experienced something similar.
However, once I implemented the OnDestroy interface in my @Injectable service, I see that ngOnDestroy gets called when the app gets bootstrapped againg by HMR.
I'm using {N} 5.3 with nativescript-dev-webpack 0.22.0
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Uh oh!
There was an error while loading. Please reload this page.
Environment
CLI: 5.0.0
Cross-platform modules:
✔ Component nativescript has 5.0.0 version and is up to date.
✔ Component tns-core-modules has 5.0.2 version and is up to date.
✔ Component tns-android has 5.0.0 version and is up to date.
✔ Component tns-ios has 5.0.0 version and is up to date.
Android Runtime: 5.0.0
iOS Runtime: 5.0.0
Plugin(s): None
Node.js: 10.12.0
Please, attach your package.json and webpack.config.js as these configurations are usually critical for investigating issues with webpack.
These are default out of the box configs from using
tns create
Describe the bug
When HMR tears down the Angular platform on changes, it correctly calls ngOnDestroy for all components etc, however it does not for services, meaning your app can end up in a weirdly initialized state with multiple "singletons" running side by side.
To Reproduce
tns create
- create a new angular project with say, the tabbed view.Insert a constructor in app/core/data.service.ts:
constructor() { console.log("DataService constructor"); }
tns run android --hmr
- the app starts, "DataService constructor" is written in console as expected.Change some text in
home.component.html
that will cause a refresh. "DataService constructor" gets output again.Expected behavior
ngOnDestroy
is a valid lifecycle hook for services as well, as mentioned here: https://angular.io/api/core/OnDestroyYou can imagine the trouble you can get in when you start including Rx Observable subscriptions in the constructor of a service, and even more when services start bootstrapping plugins.
So
ngOnDestroy
should also get called for services.The text was updated successfully, but these errors were encountered: