Hi all I've an application that until now was only doing http request to retrieve data...now the problem is that we have also a websocket but I've no idea how to combine both of them:
This is my http request:
public stock(): Observable<any> {
if (!this._stock) {
// rest api
this._stock = this.http.get(url)
.map((stock: Response) => {
// cache the value
stock.json().items.forEach((item) => {
this._stock[item.productKey] = item;
});
return this._stock;
})
.publishReplay(1)
.refCount();
}
return this._stock;
}
This is the websocket:
public getStockMessages(): Observable<any> {
return new Observable(obs => this.inventoryChannel.on(`STOCK`, (data) => {
return obs.next(data);
}));
}