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

Support for class inheritance on rxjs-prefer-angular-takeuntil #113

Open
CosmoRing opened this issue Jan 21, 2020 · 3 comments
Open

Support for class inheritance on rxjs-prefer-angular-takeuntil #113

CosmoRing opened this issue Jan 21, 2020 · 3 comments

Comments

@CosmoRing
Copy link

It's possible to add support for class inheritance on the rxjs-prefer-angular-takeuntil rule?
In the current projects i work on, all the common logic of a component is added on a BaseComponent where the subject is defined and called on the ngOnDestroy method. This method may our may not be overrided on the extended component.

An example of the most simple example is visible bellow.

export abstract class BaseComponent implements OnDestroy {
  public destroy: Subject<void> = new Subject();

  ngOnDestroy() {
    this.destroy.next(true);
    this.destroy.complete();
  }
}

@Component({
  selector: "correct-component"
})
class CorrectComponent extends BaseComponent implements OnDestroy {
  someMethod() {
    a.pipe(
      switchMap(_ => b),
      takeUntil(this.destroy)	
    ).subscribe();
  }

  ngOnDestroy() {
    super.ngOnDestroy();
  }

This same BaseCompoment may also be extended to another abstract component for more specific logic; example bellow.

export abstract class BaseComponent implements OnDestroy {
  public destroy: Subject<void> = new Subject();

  ngOnDestroy() {
    this.destroy.next(true);
    this.destroy.complete();
  }
}

export abstract class BaseFormComponent extends BaseComponent implements OnDestroy {
  
  (....generic form logic....)
  
  public ngOnDestroy() {
    super.ngOnDestroy();
	
	(....generic form logic....)
  }
}


@Component({
  selector: "correct-form-component"
})
class CorrectFormComponent extends BaseFormComponent implements OnDestroy {
  someMethod() {
    a.pipe(
      switchMap(_ => b),
      takeUntil(this.destroy)	
    ).subscribe();
  }

  ngOnDestroy() {
    super.ngOnDestroy();
  }
}
@cartant
Copy link
Owner

cartant commented Jan 26, 2020

I imagine this would be possible, but complicated and I can't see myself having the time to do this anytime soon.

@antonyboom
Copy link

Is there any chance you add this enhancement soon?

@cartant
Copy link
Owner

cartant commented Mar 16, 2020

Is there any chance you add this enhancement soon?

No. It's simply not a priority for me.

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

No branches or pull requests

3 participants