I have seen a tutorial on rxjs as like this.
My question is:
1) What is the usage of take(1) here? I see a lot of explanation online but i don't really get it. Also, i don't see any benefit of using take(1) in this code. And the author do use take(1) on every return function in REST api related service.
2) The author did not unsubscribe after subscribe. Is it because the author use take(1) therefore manual unsubscribe is not needed?
3) What if i want to implement catch function. Should i implement it before take or after take.
getProfile() { // this is a call to REST API
return this.service.getProfile()
.map(res => res.json())
.take(1)
}
}
this.data.getProfile().subscribe(profile => {
this.userProfile = profile;
});