I want to create an Observable that subscribes to another Observable and yields true on success and false on error.
This is my solution:
new Observable ((observer: Observer<boolean>) => {
obs().subscribe (() => {
observer.next (true);
}, error => {
observer.next (false);
})
});
But I think there must be an easier solution without "new Observable". Something like:
obs().pipe (
map (() => true),
catchError(() => of(false))
);
But that leaves just typescript errors:
error TS2322: Type 'Observable' is not assignable to type 'boolean | Observable'.
Type 'Observable' is not assignable to type Observable'.
Type 'boolean | {}' is not assignable to type 'boolean'.
Type '{}' is not assignable to type 'boolean'.
I am using: rxjs 5.5.2 typescript 2.4.2