如何使用 Ngxs Websocket 插件捕获错误?

How to catch errors with Ngxs Websocket plugin?

我正在尝试使用 Angular 6 + Ngxs + WebSocket 构建应用程序。但是,有些我无法连接到 Ngxs 提供的 WebSocket 插件。

在文档中,Ngxs 提到我们可以使用 WebsocketMessageError 操作捕获错误。 (我希望我正确理解了文档)

文档 Link:https://ngxs.gitbook.io/ngxs/plugins/web-socket

但我试图在我的服务中导入此操作 class,然后它说操作不可用。

这是我的 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());
  }

}

我收到以下错误:

module @ngxs/websocket-plugin/ngxs-websocket-plugin"' has no exported member 'WebsocketMessageError'.

import WebsocketMessageError

这看起来像是一个错误。请在 github 存储库中报告它: https://github.com/ngxs/store/issues