Skip to content

Introduce ESLint rule to prevent Observable-return methods from being used in Angular templates #5933

Description

@ybnd

We commonly use this pattern in DSpace Angular:

  • Component method returnSomething$() returns an Observable
  • Called from the template, with | async

Effectively this causes the RxJS pipe to be executed again for each change detection cycle, often leading to performance issues.

We should look into introducing an ESLint rule to guard against this.

Existing cases should be rewritten into the following pattern:

  • Subscribe within ngOnInit()
  • Pass emitted values to a BehaviorSubject; this will be the new target for | async
  • Unsubscribe within ngOnDestroy()

Metadata

Metadata

Assignees

Labels

Type

Fields

No fields configured for Task.

Projects

Status
🙋 Needs Help / Unscheduled

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions