I've been trying to subscribe to a particular observable(i am a beginner to rxjs), but I keep failing. here is my code
here I need to assign the first element of usergroups array element to this.currentGroup
const selectedUserGroups$ =
this.userGroupsService.getUserGroupsWithUsers(this.selectedUserGroupIds).pipe(shareReplay());
this.selectedUserGroups$.subscribe( (usergroups: UserGroup[]) =>
this.currentGroup = usergroups[0]); 
if(this.currentGroup.users?.length >0) 
{
  this.showUsersList(); 
}
but this won't work as i expected, Appreciate your help regarding this
 
    