-
Notifications
You must be signed in to change notification settings - Fork 45
Integration with zone.js #32
Description
Hello guys! I'm using this project since recently and I'm really impressed how much it improves my productivity!
For the last few days we're planning to integrate browser-sync
with the angular2-seed
project. The integration was quite straight-forward thanks to your great examples directory and TypeScript typings.
The problem we experience is in the context of execution of the synchronization commands you invoke between the different browsers. Angular 2 intercepts all asynchronous calls using zone.js (such as WebSockets, XHR, browser events, etc.) and runs its dirty checking algorithm. This means that the dirty checking of Angular 2 is automatically run when you triggerClick, however, when you sync the values of input fields or submit a form the synchronization is broken.
Although it is not completely clear whether this issue should belong to the zone.js project or browser-sync, I opened it here since I found an inconsistent way of handing the different user events.
As possible solutions for integration of both projects (zone.js and browser-sync) I see:
- Trigger all events manually with the same attributes as the source (I bet you have your reasons to not approach this way if you haven't done it yet).
- Create a separate, Angular 2 specific, browser-sync-client which runs all the sync changes inside of a zone.
- Wrap all sync commands inside asynchronous calls (
setTimeout(fn, 0)
). Although it seems quite dirty it should work in most cases.
I like solution two best since it will keep the current version of the client unchanged and only alter support for Angular 2.
Let me know what you think and keep the good work up!