2
언제 어떻게 사용합니까? Subject는 EventEmitter와 같습니다.Angular2의 RxJs 및 EventEmitter의 제목
어떻게 다시 작성하고 싶습니까?
import { Injectable} from '@angular/core';
import { Subject,BehaviorSubject } from 'rxjs';
import {Playlists} from 'channel' /** Assumes this is where you have defined your Playlists interface **/
@Injectable()
export class PlaylistService {
private _currentPlaylists$: Subject<Playlists> = new BehaviorSubject<Playlists>(null);
constructor() {}
currentPlaylists() {
return this._currentPlaylists$.asObservable();
}
setCurrentPlaylists(playlists:Playlists){
this._currentPlaylists$.next(playlists);
}
}
적절한 사용을 위해 http://stackoverflow.com/questions/36076700/what-is-the-proper-use-of-an-eventemitter를 참조하십시오 EventEmitter의 –