I recently came across a fascinating article about the Angular onPush Change Detection Strategy
where the author highlighted:
Avoid exposing your subject to external sources; always expose the observable instead by utilizing the asObservable() method.
However, he did not elaborate on the reasons behind this recommendation. Does this imply that actions such as the following should be avoided?
export class ExampleComponent {
public drawerTrigger$ = new Subject<{}>();
}
In the HTML file:
<button class="hamburgher-button" type="button"
(click)="drawerTrigger$.next($event)">
<i >menu</i>
</button>
If not, what is the correct approach to handling this situation?