I receive messages via a websocket connection in this format :
[
{
//msg 1
},
{
//msg 2
},
....
]
based on some examples I found on the web here is my code:
public messages: Subject<Message> = new Subject<Message>();
//...
this.messages = <Subject<Message>>this.wsService
.connect(COMMUNICATION_URL)
.map((response: MessageEvent): Message => {
let data = JSON.parse(response.data);
//data is an array [ {..} , {..}, ...]
return data;
});
this.messages.subscribe(msg => {
console.log(msg);
// msg is an array of objects [ {..} , {..}, ...]
// I want to be just the object
});
What I want to achieve is to split the message (array) in objects and when I subscribe I want to receive those objects and not the array of objects.