如何解决如何仅将类属性“userIsFollowing”设置为 true/false 一次?
现在,每个结果的 bool 属性都被记录到控制台。显然,如果只有一个匹配项,我只需要将其设置为 true,那么我可以在 if 语句的末尾添加 return 或 break 吗?
this.cuFollowing = this.afs.collection("users").doc(this.uid).collection("following").valueChanges({idField: 'followID'})
.subscribe(results => {
//TODO: There's multiple results!!!
for (let result of results) {
if (result.followeeUid === this.userId && result.followerUid === this.uid) {
this.userIsFollowing = true;
console.log(this.userIsFollowing);
this.unFollowID = result.followID;
}
else {
this.userIsFollowing = false;
console.log(this.userIsFollowing);
}
}
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。