我有两个变量goalsData
,goals
它们在初始加载时可以正常工作,但我想保持goal
同步,goalsData
以便如果该变化发生变化,我goalsData
将goals
如何实现这一点?
ngOnInit() {
this.goalsData = this.apollo.watchQuery({ query: GoalQuery, forceFetch: true });
this.goals = this.goalsData.map(({data}) => data.allGoals);
console.log(this.goals);
}