Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking Angular Change Detection #89

Open
aker99 opened this issue Jul 18, 2020 · 2 comments
Open

Blocking Angular Change Detection #89

aker99 opened this issue Jul 18, 2020 · 2 comments

Comments

@aker99
Copy link

aker99 commented Jul 18, 2020

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
Copy link
Collaborator

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
Copy link

uhmarcel commented Feb 19, 2022

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);
      });
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants