Ionic-framework: NavController lifecycle events interfaces

Created on 2 Aug 2016  路  8Comments  路  Source: ionic-team/ionic-framework

Short description of the problem:

_NavController_'s lifecycle events should have interfaces.

What behavior are you expecting?

Provide interfaces, which compel us to implement the corresponding methods like OnInit in Angular2, in order to benefit from typing and editor tooling.

Which Ionic Version? 1.x or 2.x
2.x

Most helpful comment

These interfaces assure that a component implements the hooks correctly; it eliminates the possibility of typos. Even if the methods should be renamed in the future, we could detect that change.

Besides, we could benefit from an IDE.
Without these interfaces, we have to refer to the doc page to remember the name of the methods every time. But some IDEs are intelligent enough to suggest apposite candidates in an import sentence.

For example, we only have to type On in the curly brackets below to see the list of the lifecycle interfaces provided by Angular2: OnInit, OnChanges, and OnDestroy.

import { } from '@angular/core';

We only have to choose one of them and declare it in order to know which methods should be implemented if interfaces are provided.

I think it would be nice that ionic could provide such features. Thanks. :)

All 8 comments

Hello! Thanks for opening an issue with us! Would you mind explaining a little more about your suggestion? To hook into a lifecycle event you simply use http://ionicframework.com/docs/v2/api/components/nav/NavController/#lifecycle-events , so I am a little unclear of why these would need an interface of any kind. Thanks for using Ionic!

These interfaces assure that a component implements the hooks correctly; it eliminates the possibility of typos. Even if the methods should be renamed in the future, we could detect that change.

Besides, we could benefit from an IDE.
Without these interfaces, we have to refer to the doc page to remember the name of the methods every time. But some IDEs are intelligent enough to suggest apposite candidates in an import sentence.

For example, we only have to type On in the curly brackets below to see the list of the lifecycle interfaces provided by Angular2: OnInit, OnChanges, and OnDestroy.

import { } from '@angular/core';

We only have to choose one of them and declare it in order to know which methods should be implemented if interfaces are provided.

I think it would be nice that ionic could provide such features. Thanks. :)

@jgw96 These interfaces follow the design of Angular 2 with OnInit, etc.

I could maybe make a PR to add them.

@fknop that would be awesome! Let me know if you need any help!

@jgw96 https://github.com/driftyco/ionic/issues/7770 But you already answered it!

I already commited on my repo (https://github.com/fknop/ionic/commit/0b59b4807e9c04bbc0f136428800dee0b2845d2d), I'm just waiting to fix the tests problem to submit the PR.

@jvbianchi @fknop @ValterSantosMatos @ysgk
please feedback!! https://github.com/driftyco/ionic/pull/10649

I love it @manucorporat.
Is there a reason why this is not being included in the previous releases?

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.

Was this page helpful?
0 / 5 - 0 ratings