Reputation: 263
Trying to get data from firebase, but grouped 4 by 4. How would I manage to group and return an observable of 4 in 4.
# input
# [1, 2, 3, 4, 5, 6, 7, 8]
# output
# [ [1,2,3,4], [5, 6, 7, 8]...]
I have tried this, but it only takes the first 4 and returns an array and not as an observable
this.data$ = this.afs
.collection<Data>('data')
.valueChanges()
.pipe(take(4), toArray());
Upvotes: 1
Views: 179
Reputation: 8022
bufferCount
this.data$ = this.afs
.collection<Data>('data')
.valueChanges()
.pipe(bufferCount(4));
Upvotes: 2
Reputation: 534
I think you're explicitly making the return type an array by using .pipe(take(4), toArray());
. Try removing the second parameter toArray()
.
Upvotes: 0