我正在通過official cookbook來學習Angular2。Angular2中的'rxjs/Subject'是什麼?
下面的代碼突然出現了。爲什麼「missionAnnounced $」沒有變量聲明?讓missionAnnounced $ = ... 以下代碼的邏輯是什麼?
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
@Injectable()
export class MissionService {
// Observable string sources
private missionAnnouncedSource = new Subject<string>();
private missionConfirmedSource = new Subject<string>();
// Observable string streams
missionAnnounced$ = this.missionAnnouncedSource.asObservable();
missionConfirmed$ = this.missionConfirmedSource.asObservable();
// Service message commands
announceMission(mission: string) {
this.missionAnnouncedSource.next(mission);
}
confirmMission(astronaut: string) {
this.missionConfirmedSource.next(astronaut);
}
}
https://github.com/Reactive-Extensions/RxJS – zerkms