0

单击按钮后,我正在尝试在firebase中更新列表(增加列表中的值),但是,每当我单击按钮时,除非我关闭页面选项卡,否则该值会不断增加而不会停止。

onRecipeUpvote(recipe: Recipe)
{
    // get list with -> name: recipe.name
    let listRecipe = this.ngFireDB.list<Recipe>('/recipes', ref => ref.orderByChild('name').equalTo(recipe.name));

    listRecipe.snapshotChanges().map(actions => {
      return actions.map(action => ({ key: action.key, ...action.payload.val() }));
    }).subscribe(items => {
      return items.map(item => {
        // Increment its current upvotes by 1
        listRecipe.update(item.key, { upvotes: item.upvotes + 1 });           
      });
    });  
}
4

1 回答 1

1

功能完成后尝试手动取消订阅。

于 2018-04-16T05:15:54.397 回答