I try to forkJoin a custom Observable (rxjs 5.5.6)
import { forkJoin } from 'rxjs/observable/forkJoin';
forkJoin(
this.resources.loadRefsCatalog()
).subscribe((res) => {
// I'm never executed :(
});
and the target is
public loadRefsCatalog(): Observable<any> {
console.log(1);
return new Observable((observer) => {
console.log(2);
// doing something
});
}
I got well the 1 and 2 in console log but i never fall in the subscribe of the forkJoin.
I try some return with {unsubscribe(){}} and observer.complete() but no change. So i'm stuck without idea of why.
Thanks in advance for any ideas.
// Off course my forkJoin is for multiple queries and others are http observable and run well, but not my own observable. I tried a lot of combination.
Solution is
public loadRefsCatalog(): Observable<any> {
return new Observable((observer) => {
this.dataProvider.loadRefsCatalog().subscribe((res) => {
this.refsCatalog = res;
observer.next(true);
observer.complete();
});
});
The key is next(a_value) and complete(), butmostly next() for the forkJoin.
observer.next(...whatever you want to send to forkJoin...);