How to manage downloading data in Ionic


#1

I have small issue with managing the downloading data of firebase to my ionic application.

For example: In the normal case [such as below code], the downloading data is normal [such as this image]

constructor(...){
    this.questionsList = this.afd.list('/questions/');
}

But if I used “setInterval” [such as below code], the downloading of data increase [such as this image]

constructor(...){
    this.questionsList = this.afd.list('/questions/');
    this.favoritesList = this.afd.list('/favorites/',{
        query:{
            orderByChild:'user_id',
            equalTo: userService.id,
        }
    })

    this.joinObjects();
    this.refreshIntervalId=setInterval(()=>{
        this.joinObjects();
    },250);
}

joinObjects(){
    let TempListX=[];
    this.favoritesList.take(1).subscribe(data1=>{
        this.questionsList.take(1).subscribe(data2=>{
            TempListX = data1.slice(0);
            for(let i=0; i<data1.length; i++){
                for(let j=0; j<data2.length; j++){
                    if(data1[i].question_id==data2[j].$key){
                        TempListX[i].qTitle=data2[j].title;
                    }
                }
            }
            if (JSON.stringify(TempListX)===JSON.stringify(this.TempFavoritesList)) {
            }else{
                this.TempFavoritesList=TempListX.slice();
            }
        })
    })
}

So is there any way to make the downloading data be such as normal case ?