Can unsubscribe for AngularEventEmitter

Hello, I have a directive that extend the dropdownbutton component and inside its subscribing to the beforeItemRender.

I want to know if is needed to unsubscribe on destroy and how to do it because is a AngularEventEmitter

Thanks

3 Replies 1 reply marked as answer

MK Mohan Kumar Ramasamy Syncfusion Team January 12, 2021 03:55 AM UTC

Hi Cesar, 
 
We have checked your reported query. We can unsubscribe the beforeItemRender event in destroy. For your reference, we have prepared a sample based on this. Please refer below link. 
 
 
 
export class AppComponent { 
  subscription: any; 
  constructor(private syncService: SyncService) {} 
  ngOnInit() { 
    this.subscription = this.syncService 
      .getNavChangeEmitter() 
      .subscribe(item => this.beforeItemRender(item)); 
  } 
 
   
`Other Folder...` item. 
  public beforeItemRender(args: any) { 
    console.log("Triggered"); 
  } 
  public destroy(args: any) { 
    this.subscription.unsubscribe(); 
  } 
} 
 
       <div class="col-xs-12 col-sm-12 col-lg-6 col-md-6"> 
                    <button ejs-dropdownbutton [items]='items' content="Profile" iconCss="e-ddb-icons e-profile" (beforeItemRender)='beforeItemRender($event)' (destroy)='destroy($event)'></button> 
                </div> 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Mohankumar R 


Marked as answer

CS Cesar Smerling January 12, 2021 12:06 PM UTC

Thanks, that work.


MK Mohan Kumar Ramasamy Syncfusion Team January 12, 2021 12:19 PM UTC

Hi Cesar,   
  
Thanks for the update.  
 
We are happy to hear that your requirement has been fulfilled. Please feel free to contact us if you need any further assistance on this. 
 
Regards, 
Mohan kumar R 


Loader.
Up arrow icon