So I have a case where I listen to multiple event listners, such as click, pointermove etc like this:
const activity$ = merge(
fromEvent(window, 'click'),
fromEvent(window, 'pointermove'),
).pipe(
throttleTime(500),
share(),
);
Now in my ActivityService, I inject this result into a subject like so:
activity$.subscribe(this.activitySubject);
I surround both of these statements with a NgZone.runOutsideAngular and it avoids unnecessary change detection succesfully.
However, the handlers outside of this service that subscribe to activitySubject should run back inside the Angular Zone conditionally. I don't want it to happen for every activitySubject emission, but based on a conditional check (timeouts I have setup basically).
When I use NgZone.run for this, it causes the original activity to trigger change detection again for every 500ms (due to my throttle).
I'm not understanding how this works properly and I'm possibly taking the wrong approach.
Any advice?