Filter/split observable by property


#1

I want to split an observable array (cursor) into two separate streams based on a string property value on the observable object.

I’m using meteor observable like so:

this.entitiesSub = MeteorObservable.subscribe('entities', this.jobId).subscribe(() => {
      this.entities = Entities.find({"job.jobId":jobId });

then I would like to create two new streams like so:

this.stream1 = this.entities.filter(x => x.type == "test1");
this.stream2 = this.entities.filter(x => x.type == "test2");

But this doesn’t seem to work. I read somewhere you have to make the observable “hot” (I still don’t really understand that), so I tried the following and then filtering from that but still no luck…:

this.hotEntities = this.entities.share();


#2

I’ve managed to get it filtering and logging to the console correctly using mergeAll()

this.stream1 = this.entities.mergeAll().filter(x => x.type == "test1").subscribe(x => console.log(x));

But I think this is no longer an array of observables after that? So it no longer works in my ngFor loop. How can I filter it then convert it back to an observable array?