vrn-dev / ng6-socket-io

Socket.IO module for Angular 6 and RxjS 6
MIT License
5 stars 11 forks source link

Cannot read property 'runOutsideAngular' of undefined #3

Closed GabriMagic closed 6 years ago

GabriMagic commented 6 years ago

Hello, I'm trying to use this with my Angular 6, I have the app.module config:

SocketIoModule.forRoot(config)

And simple chat service:

import { Injectable } from '@angular/core';
import { Socket } from 'ng6-socket-io';
import { map } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class ChatService {

  constructor(private socket: Socket) {
    console.log('Init ChatService');
  }

  sendMessage(msg: string) {
    this.socket.emit('message', msg);
  }

  getMessage() {
    return this.socket.fromEvent('message').pipe(map(data => data));
  }
}

And when I go to the web, I get this in the console:

image

christian-quisbert commented 6 years ago

i have the same problem.. ng-problem

jimisjames commented 6 years ago

any solution to this?

christian-quisbert commented 6 years ago

No, but use this library that solve the problem : ngx-socket-io npm i ngx-socket-io