I store a stream as a variable then subscribe to it 3 times.
As I imagined it at first, it will perform an action then at the end get the data next it triggers and everybody will get its one update. It was wrong because it performs an action for every subscriber, means many API calls in this case. If I create a Subject then subscribe with it to the Observer and make anybody else to subscribe to this Subject then it works. Unfortunately, I am new in RP could you explain to me what is happening here?
this.listStream = Observable
.interval(this.refreshInterval)
.do(() => console.log('call the api 3 times'))
.map(i => fruitApiStream)
.startWith(fruitApiStream)
.flatMap<FruitDto[]>(s => s)
.map<Fruit[]>(
s => s.map(s => {
return new Fruit(s.fruitId, s.name);
}));