Created
January 4, 2024 08:39
-
-
Save anandadake/69b1069c9ca15f53b7b2ff27adcbc8fc to your computer and use it in GitHub Desktop.
Angular Memory Leak Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { catchError } from 'rxjs'; | |
| import { FormBuilder } from '@angular/forms'; | |
| import { Component, OnDestroy, OnInit } from '@angular/core'; | |
| import { ToastrService } from 'ngx-toastr'; | |
| @Component({ | |
| selector: 'app-brush', | |
| templateUrl: './brush.component.html', | |
| styleUrls: ['./brush.component.css'] | |
| }) | |
| export class BrushComponent implements OnInit, OnDestroy { | |
| private subscriptions$:any = []; | |
| constructor( | |
| private fb: FormBuilder, | |
| private toastr: ToastrService, | |
| private apiService:WorkspaceApiService, | |
| private stateService:WorkspaceStateService, | |
| ) { } | |
| ngOnInit(): void {} | |
| ngOnDestroy(): void { | |
| this.subscriptions$.forEach((subscription:any)=>subscription.unsubscribe()); | |
| } | |
| onSave(event:any){ | |
| this.subscriptions$.push(this.apiService.brush_add_api({}) | |
| .pipe( | |
| catchError((e)=>{ | |
| this.toastr.error(e.error.msg, "API Error!");return e; | |
| }), | |
| ) | |
| .subscribe((resp:any) => { | |
| this.stateService.setProjectInfoState(resp.data.project_info); | |
| this.toastr.success('Your changes have been saved successfully!', "Successful"); | |
| } | |
| )); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment