The subscribe method in Angular comes from the RxJS library using Angular internally as an observable. It is used to synchronously and asynchronously stream data into components or services which have subscribed to the same observable type.

Here’s an example of subscribe method being used to subscribe to users to any new magazines published by the Magainze Store.

Our aim while creating Angular 4 Interview Questions and Answers, is to help you grow as a Frontend Developer. The questions mentioned here have been asked by leading organizations during technical rounds of the interview process.

BY Best Interview Question ON 12 Jun 2020

Example

let subscription = magazineStore.getMagazines().subscribe(
   (newMagazine)=>{
          console.log('newMagazine',newMagazine);
    });