Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Socket.IO #828

Closed
Closed

Description

@Kaffiend

Is there a way we can get Socket.io to run within zone? or will we manually have to run every socket callback through zone?

Activity

  1. JiaLiPassion commented on Jul 1, 2017

    @JiaLiPassion
    Collaborator

    @Kaffiend ,currently you have to use Zone.current.wrap(callback) yourself, I can implement a patch for socket.io later.

  2. devbdavis commented on Sep 22, 2017

    @devbdavis

    I guarantee this is not optimal, but the only way I found to wrap the emitter .on event, was something like this:

    let socketOn = socket.on;
    socket.on = (event: string, fn: () => any) => {
      let wrappedFunction = function() {
        let args = arguments;
        zone.run(() => fn.apply(this, args));
      };
      return socketOn.apply(socket, [event, wrappedFunction]);
    };
  3. devbdavis commented on Sep 22, 2017

    @devbdavis

    Although, its weird. I do see that websockets themselves are wrapped. socket.io uses the Component Emitter for handling its events: https://www.npmjs.com/package/component-emitter

  4. Kaffiend commented on Sep 22, 2017

    @Kaffiend
    Author

    I added ngrx to manage state better and discovered that onPush change detection and async slices of state updated from my socket services makes this work just fine. Not saying it doesnt need patched for other implementations without a reactive library for angular in use.

  5. Kaffiend commented on Jan 4, 2018

    @Kaffiend
    Author

    Will zone be patched any time soon for Socket.IO?

  6. JiaLiPassion commented on Jan 5, 2018

    @JiaLiPassion
    Collaborator

    @Kaffiend , I am working on it, I will create a PR soon.

  7. added 6 commits that reference this issue on Jan 16, 2018
    f3b5816
    0119f16
    35d482c
    85e737c
    52b738f
    2469bc9
  8. added 2 commits that reference this issue on Feb 8, 2018
    6885151
    b240946
  9. added a commit that references this issue on Feb 8, 2018
    b3db9f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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