title: How to subscribe to a private Event Emitter in Angular
body: <p>I have a service which has an Event Emitter say &quot;E&quot;. Right now E is a public variable. I am on Angular 11.</p>
  <ul>
  <li>Is there a way I can use public functions to allow other components to subscribe to E and keep E as private?</li>
  <li>Is it good practice to keep Event Emitters as private, or do we usually have them as public?</li>
  </ul>
  <p>P.S. If there are better ways to do this (Observables etc.), go easy on me, I'm taking an Angular course and haven't reached there yet.</p>
  <p>For example, this is my service where I have the Event Emitter</p>
  <pre><code>export class ShoppingListService {
      public ingredientsChanged = new EventEmitter&lt;Ingredient[]&gt;();
  }
  </code></pre>
  <p>And this is my component where I subscribe to it:</p>
  <pre><code>export class ShoppingListComponent implements OnInit {
    ingredients: Ingredient[];
  
    constructor(private shoppingListService: ShoppingListService) {}
  
    ngOnInit(): void {
      this.ingredients = this.shoppingListService.getIngredients();
  
      this.shoppingListService.ingredientsChanged.subscribe(
        (ingredients: Ingredient[]) =&gt; {
          this.ingredients = ingredients;
        }
      );
    }
  }
  </code></pre>