I am trying to build an application using Angular 6 + Ngxs + WebSocket. However, some how I am not able to connect with the WebSocket plugin provided by Ngxs.
In the documentation, Ngxs mentioned that we can catch the error using WebsocketMessageError action. (I hope I understood the documentation correctly)
Documentation Link: https://ngxs.gitbook.io/ngxs/plugins/web-socket
But I am trying to import this action in my Service class, then it says that Action is not available.
Here is the code of my WebSocketService class.
import { Injectable } from '@angular/core';
import { Store, Actions, ofActionDispatched } from '@ngxs/store';
import { WebsocketMessageError, ConnectWebSocket } from '@ngxs/websocket-plugin';
import * as Rx from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class WebSocketService {
private subject: Rx.Subject<MessageEvent>;
constructor(private store: Store, private actions$: Actions) {
this.actions$
.pipe(ofActionDispatched(WebsocketMessageError))
.subscribe(({ payload }) => {
console.log('Got action: ', payload);
});
}
public connect() {
this.store.dispatch(new ConnectWebSocket());
}
}
I am getting following error:
module @ngxs/websocket-plugin/ngxs-websocket-plugin"' has no exported member 'WebsocketMessageError'.
import WebsocketMessageError
This looks like a bug. Please report it in the github repository: https://github.com/ngxs/store/issues