Я пытаюсь реализовать очень простое приложение Angular на основе WebSockets, которое я получил из примера. Соединение устанавливается следующим образом:
public connect(url): Subject<MessageEvent> {
if (!this.subject) {
this.subject = this.create(url);
console.log('Successfully connected: ' + url);
}
return this.subject;
}
И вот как я пытаюсь адаптировать вывод из нашего веб-сокета, но .map не существует, и я смотрел как обрабатывать тему, и я просто не могу ее обработать
public messages: Observable<Message>;
constructor(private wsService: WebsocketService) {
this.messages = wsService.connect(CHAT_URL).map(
(response: MessageEvent): Message => {
const data = JSON.parse(response.data);
return {
author: data.author,
message: data.message
};
}
);
}
EDIT Я получаю следующую ошибку:
error TS2339: Property 'map' does not exist on type 'Subject<MessageEvent>'.