Consider this simple snippet of angular2/rxjs/typescript
public rooms: Observable<Room[]>;
constructor ( ... ) {
this.rooms = this.inspectShipSubject
.do(() => console.log('foo'))
.switchMap(ship => this.roomByShipService.getRoomsByShip(ship));
//this.rooms.subscribe(); // <-- [1]
}
Here's the template:
<some-component *ngFor="let room of rooms | async" [room]="room"></some-component>
It doesn't work ('foo' is not printed and no data shows) unless I uncomment the line indicated [1]. Why doesn't the template trigger the observable to execute automatically?
Is there a better way than to use a blank subscribe?
(rooms | async)into parenthesis?