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 }}
Repository navigation
[v4-beta.18] constants for lifecycle hooks are no longer exported #16760
Current behavior:
Since 119e0c1 its impossible to get a reference to the names of the lifecycle hooks (like LIFECYCLE_DID_ENTER) as they are no longer exported. I had to import them directly via from '@ionic/core/dist/collection/components/nav/constants.js'
and had to add ".js" otherwise jest didn't find the file...
Expected behavior:
LifeCycleHook constants should be exported via any of the index.ts files.
I don't know if this use case was never considered or if I missed some design paradigm that would solve this. I could just hardcode them as strings ["ionViewDidEnter"] but that feels like an even worse code smell.
The actual use case is for dynamically adding resource intensive listeners (e.g onResize) for the active page and remove them when it leaves - so that we don't keep the onResize listeners for the pages active that aren't visible at the moment.
A specific example is a directive that refocuses an input element after device rotation if it was focused beforehand.
Be aware that this was all developed with ionic3 in mind so maybe it would be better to replace it with a completely different approach, like subscribing to angular router navigation events and then checking if the current directive is on the page with the active route...
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
manucorporat commentedon Dec 16, 2018
What's your use case?
Farbdose commentedon Dec 16, 2018
I need to execute code in response to the didEnter and didLeave events, from the execution context of a directive.
https://forum.ionicframework.com/t/ionic-4-how-can-i-access-the-lifecycle-hooks-from-a-directive/148155
I don't know if this use case was never considered or if I missed some design paradigm that would solve this. I could just hardcode them as strings ["ionViewDidEnter"] but that feels like an even worse code smell.
The actual use case is for dynamically adding resource intensive listeners (e.g onResize) for the active page and remove them when it leaves - so that we don't keep the onResize listeners for the pages active that aren't visible at the moment.
A specific example is a directive that refocuses an input element after device rotation if it was focused beforehand.
Be aware that this was all developed with ionic3 in mind so maybe it would be better to replace it with a completely different approach, like subscribing to angular router navigation events and then checking if the current directive is on the page with the active route...
fix(core): export ionic lifecycle names
ionitron-bot commentedon Jan 15, 2019
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.