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

Create OnUiParamsChanged, OnUiExit interfaces instead of Ng2Component #788

Closed
stnor opened this issue May 14, 2020 · 4 comments
Closed

Create OnUiParamsChanged, OnUiExit interfaces instead of Ng2Component #788

stnor opened this issue May 14, 2020 · 4 comments

Comments

@stnor
Copy link
Contributor

stnor commented May 14, 2020

It would be nice with separate interface exports for the hooks, and with a nice naming, such as:

export interface MyComponent implements OnUiExit {
   uiCanExit(newTransition?: Transition): HookResult {
   }
}

As it is right now the NG2Component interface really does not add any declarative meaning for a person using the framework, imho:

export interface MyComponent implements Ng2Component {
}

I don't get why a user-exposed interface has this design with all optional methods. I feel that its better to have one interface per hook and not use the optional (?) syntax.

export interface Ng2Component extends Component {

   uiOnParamsChanged?(newParams: {
        [paramName: string]: any;
       }, trans?: Transition): void;

   uiCanExit?(newTransition?: Transition): HookResult;
}

Any chance of getting this? I could create my own interfaces, but feel it's better if it's in the framework. Thanks.

@stnor stnor changed the title Create OnParamsChanged, CanExit interfaces instead of Ng2Component Create OnUiParamsChanged, OnUiExit interfaces instead of Ng2Component May 14, 2020
@christopherthielen
Copy link
Member

That sounds good to me. Would you like to take a shot at a PR?

@stnor
Copy link
Contributor Author

stnor commented May 28, 2020

Sure, I'll give it a try later this week.

@stnor
Copy link
Contributor Author

stnor commented May 28, 2020

@christopherthielen Should I remove, deprecate or leave "Ng2Component" as is?
It's only used internally in uiView.ts:214, so removing it makes sense to me, but that may obviously break some projects that use it.

stnor added a commit to stnor/ui-router-angular that referenced this issue May 28, 2020
stnor added a commit to stnor/ui-router-angular that referenced this issue May 28, 2020
@stnor
Copy link
Contributor Author

stnor commented May 28, 2020

PR #800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants