I have a basic simple service, which I utilized from here, There are very similar resource examples like this.https://jasonwatmore.com/post/2018/06/25/angular-6-communicating-between-components-with-observable-subject
export class BasicService {
private messageSource = new Subject();
currentMessage = this.messageSource.asObservable();
constructor() { }
changeMessage(currentMessage) {
this.messageSource.next(currentMessage);
}
}
When I tried unsuscribing on component which receives data, it says
unsuscribe function does not exist.
How would I modify service function above to allow unsuscribe?
ngOnDestroy() {
this.copyChangeAddressService.unsubscribe();
}
from Angular: Service Unsubscribe Function on basic Subject Observable
No comments:
Post a Comment