Skip to content
This repository was archived by the owner on Oct 13, 2018. It is now read-only.
This repository was archived by the owner on Oct 13, 2018. It is now read-only.

Integration with zone.js #32

@mgechev

Description

@mgechev

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:

  1. 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).
  2. Create a separate, Angular 2 specific, browser-sync-client which runs all the sync changes inside of a zone.
  3. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions