我尝试使用firebase后端重新创建这个无限滚动的简单示例:https://angularfirebase.com/lessons/infinite-scroll-with-firebase-data-and-angular-animation/
问题是我想使用最新版本的angularfire2,而我却无法弄清楚如何重写1方法。
我坚持使用movies-list.components.ts文件的getMovies()方法,因为在最新版本的angularfire2中没有' do()&# 39; AngularFireList对象的方法。有没有办法在.take(1).subscribe()?
之前运行任意代码private getMovies(key?) {
if (this.finished) return
this.movieService
.getMovies(this.batch+1, this.lastKey)
.do(movies => {
/// set the lastKey in preparation for next query
this.lastKey = _.last(movies)['$key']
const newMovies = _.slice(movies, 0, this.batch)
/// Get current movies in BehaviorSubject
const currentMovies = this.movies.getValue()
/// If data is identical, stop making queries
if (this.lastKey == _.last(newMovies)['$key']) {
this.finished = true
}
/// Concatenate new movies to current movies
this.movies.next( _.concat(currentMovies, newMovies) )
})
.take(1)
.subscribe()
}
答案 0 :(得分:1)
do()
在RxJS 6+中称为tap()
。