Skip to content
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

[v4-beta.18] constants for lifecycle hooks are no longer exported #16760

Closed
Farbdose opened this issue Dec 15, 2018 · 3 comments
Closed

[v4-beta.18] constants for lifecycle hooks are no longer exported #16760

Farbdose opened this issue Dec 15, 2018 · 3 comments
Labels

Comments

@Farbdose
Copy link

Farbdose commented Dec 15, 2018

Bug Report

Ionic version:

[x] 4.x

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.

Related code:

https://github.com/ionic-team/ionic/blob/v4.0.0-beta.18/core/src/components/nav/constants.ts

@ionitron-bot ionitron-bot bot added the triage label Dec 15, 2018
@manucorporat
Copy link
Contributor

What's your use case?

@manucorporat manucorporat added the needs: reply the issue needs a response from the user label Dec 16, 2018
@ionitron-bot ionitron-bot bot removed the triage label Dec 16, 2018
@Farbdose
Copy link
Author

Farbdose commented 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...

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Dec 16, 2018
manucorporat added a commit that referenced this issue Dec 16, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented 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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jan 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants