What happens when you subscribe varies from observable to observable. If you subscribe programmatically, then you need to unsubscribe, otherwise you will have a memory leak. If you use Angular's async pipe, that's handled for you.
On Sat, Sep 22, 2018, 14:20 Ilia Ternovich <[email protected]> wrote: > Thanks for the advice, pipes are very cool! > > May I ask what happens technically when I subscribe several times? Is > subscription stored somehow inside Observable? Or it is disposed after call > is done? > > loadItems(){ > this.istService.getItems().subscribe((data: Item[]) => { > this.items= data; > console.log(this.items); > }); > } > > Thanks > > On Thu, Sep 20, 2018 at 5:41 PM Sander Elias <[email protected]> > wrote: > >> Hi Tillias, >> >> Don't subscribe in your component, but use the async pipe. If you would >> have provided a stackBlit/plucker/... it would be easier to help you. >> > -- > You received this message because you are subscribed to the Google Groups > "Angular and AngularJS discussion" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- Lucas Lacroix Computer Scientist Advanced Technology Division, MEDITECH <http://ehr.meditech.com/> 781-774-2293 -- <https://ehr.meditech.com/expanse> <https://www.linkedin.com/company/meditech> <https://twitter.com/MEDITECH> <https://www.facebook.com/MeditechEHR> Subscribe <https://info.meditech.com/get-great-meditech-content?hsCtaTracking=864299ec-5abf-4004-9c6d-2d051794101f%7Cc911be42-538a-4a48-8dca-a6d4001c6326> to receive emails from MEDITECH or to change email preferences. -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
