I can read in rxjs documentation (http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-scan) for the method scan there is a seed arguement.
In the below code, I would like to return a default value for _channels Observables.
export interface IChannelOperation extends Function {
(channels: Channel[]): Channel[];
}
let initialChannel: Channel[] = [];
@Injectable()
export class ChannelsCatalog{
defaultChannel: Subject<Channel> = new BehaviorSubject<Channel>(null);
private _currentChannel: Subject<Channel> = new BehaviorSubject<Channel>(null);
private _channels: Observable<Channel[]>;
private _updates: Subject<any> = new Subject<any>();
constructor(){
this._channels = this._updates
.scan((channels: Channel[], operation: IChannelOperation) => operation(channels), initialChannel)
.publishReplay(1)
.refCount();
}
getAllChannelsCatalog(): Observable<Channel[]>{
return this._channels;
}
}
But the seed argument isn't return when I subscribe to the observable ex:
var channelsCatalog = new ChannelsCatolog();
channelsCatalog.getAllChannelsCatalog.subscribe((value) => console.log(value));
startWith()maybe that helps. - olsn