I have an existing array that as I scroll, I am trying to add more elements to.
I am using rss2json to convert an rss feed to json.
ngOnInit() {
this.getRssFeed(); // returns 4 items
}
Here is how I am adding more items:
this.count++;
this.podcastService.getRssFeed(this.rssUrl, this.count)
.then(data => {
if (data) {
for (const episodes of data.items) {
this.episodes.push(episodes); // returns 5 items
// const episode = this.episodes[episodes.length - 1]
}
event.target.complete();
console.log(data);
...
Count is correctly getting incremented. But each time getRssFeed
is called the entire array is returned. Each time with the correct length.
I am not sure how to pop
all of the array elements that come back except for the last one.
I've also tried something like this to try and push()
only the last array element returned. Still no luck.
const episode = this.episodes[episodes.length - 1]
For example, if on initial load I get:
[foo, bar]
when I scroll, I am getting back:
[foo, bar, baz]
I only want to add baz
to the already existing array.
Thank you for any suggestions!