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

Avoid using forwardRef considerations #56

Closed
kamarouski opened this issue Jul 7, 2016 · 1 comment
Closed

Avoid using forwardRef considerations #56

kamarouski opened this issue Jul 7, 2016 · 1 comment

Comments

@kamarouski
Copy link

kamarouski commented Jul 7, 2016

I didn't find aby mentions of this rule in official styleguide.

https://angular.io/styleguide

There are some cases where we need forwardRef:

  1. Resolve cycle dependencies. I know, I know you tell me it's a bad design, but sometimes we do have them. For example when rendering tree structure of similar components (A renders B, B renders A etc.). It's a valid scenario and cannot be ignored.
  2. ngModel implementation. It's probably just because I didn't find a better way to implement this. Imagine you need implement custom input component that supports ngModel property (e.g. <my-input [(ngModel)]="value" >) To achieve this we need two things:
  3. Implement ControlValueAccessor for our component,
  4. Create custom Control Value Accessor like
export const CSN_MY_INPUT_CONTROL_VALUE_ACCESSOR = new Provider(
    NG_VALUE_ACCESSOR, {
        useExisting: forwardRef(() => MyInputComponent),
        multi: true
    }
);
@mgechev
Copy link
Owner

mgechev commented Jul 7, 2016

Yes, subset of the styles from this style guide moved to the official one after a lot of discussions and meetings. forwardRef is not one of the issues that we agreed to be part of the official style guide.

Since, as mentioned in the readme, this repo is already deprecated, you can join the discussion here angular/angular.io#1151.

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