Is there a way to confirm if the ngOnDestroy method in my UserServiceService class is functioning properly? I want this service to continue running until the project starts and ends, with ngondestroy method executing once the application (website) is closed.
export class UserServiceService implements OnDestroy {
subsc: Subscription;
constructor(private auth: AngularFireAuth, private db: AngularFireDatabase, private fnc: AngularFireFunctions, private router: Router, private tostr: ToastrService) {
this.subsc = this.auth.authState.subscribe((user) => {
if (user) {
this.db.database.ref("users/" + user.uid + "/shopCart/").on("value", snap => {
});
} else {
// Not a user
}
});
}
ngOnDestroy(): void {
console.log("Closed");
this.subsc.unsubscribe();
this.db.database.ref("users/" + this.currentUserId + "/shopCart/").off();
}
}