becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Blocking Angular Change Detection #89

Open aker99 opened 4 years ago

aker99 commented 4 years ago

I'm using this plugin with Ionic 5 and Angular 9 in my project. And whenever I call zeroconf.watch(), it somehow blocks automatic change detection of angular components and I need to call change detection manually. Even after calling zeroconf.unwatch() the problem persists. PS: If I just import the package and don't use it, I don't face any issue.

emcniece commented 3 years ago

How are you importing and binding this inside your component, can you provide an example? I recall that Angular has some workarounds for thread-blocking things but it sucks if this plugin messes up mutation just by using it.

uhmarcel commented 2 years ago

I also experienced this issue:

When running Zeroconf.watch(...).subscribe(...), angular would not detect any changes inside the subscribe method until it completes.

I was able to solve it by wrapping the code inside subscribe() with ngZone:

Zeroconf
.watch(...)
.subscribe((devices) => {
      this.ngZone.run(() => {
        this.discoveredDevices$.next(devices);
      });
})