ionescu77 / raz-websocket-angular

Simple Angular 11 RxJs Websocket via echo.websocket.org
1 stars 0 forks source link

NG RxJs Websocket: disable serialization #6

Open ionescu77 opened 3 years ago

ionescu77 commented 3 years ago

https://dev.to/anthonyikeda/quickest-websockets-with-quarkus-and-angular-10-1e2c

When creating a WebSocket connection with RXJS, the default serialization/deserialization is JSON.parse. Since we are using plain test on our server side component, we will override the serde without parsing the data.

connect(): Observable<any> {
    this.connection$ = webSocket({
      url: `${env.socket_endpoint}/chat/angularuser`,
      deserializer: ({data}) => data,
      serializer: ({data}) => data,
    });
    return this.connection$;

https://github.com/ionescu77/raz-websocket-angular/blob/bb44db38ba34d89e15e8f6fa17fdb196752007a3/src/app/_services/socket.service.ts#L15

ionescu77 commented 3 years ago

Bullshit above

connect(): Observable<any> {
    this.connection$ = webSocket({
      url: `${env.socket_endpoint}/chat/angularuser`,
      deserializer: (data) => data,
      serializer: (data) => data,
    });
    return this.connection$;