In my angular app, I have a state stored in a service as a BehaviorSubject, when data comes from server I call the next function to update data and to notify all subscribers.
PseudoCode:
ajaxCall_1 -> updateData(response2)
ajaxCall_2 -> updateData(response2)
ajaxCall_3 -> updateData(response3)
...
private data$:Observable<any>;
public updateData(newData){
var currentData = data$.value;
data$.next({...currentData , ...newData})
}
Since a lot of components subscribed to that BehaviorSubject, I think it can cause some performance issue when my app is loading: on load there's a lot of notifications from server and each time next function is called components are rendering.
Do you think if I delayed the call to the next after something like 500 ms I will see performance improvement? What will be the rxjs way to delay the next call?
unsubscribemaybe help you - Hasan Fathi