Skip to content

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

Closed

Description

@Farbdose

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

Activity

  1. manucorporat commented on Dec 16, 2018

    @manucorporat
    Contributor

    What's your use case?

  2. added
    needs: reply
    on Dec 16, 2018
  3. Farbdose commented on Dec 16, 2018

    @Farbdose
    Author

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

  4. added and removed
    needs: reply
    on Dec 16, 2018
  5. added a commit that references this issue on Dec 16, 2018
    bc203a6
  6. ionitron-bot commented on Jan 15, 2019

    @ionitron-bot

    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.

  7. locked and limited conversation to collaborators on Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions