I am facing a situation where I have a class structured like this:
class Consumer {
consume(event: Observable<void>) {
event.subscribe(() => console.log('Something happened'));
}
}
The issue arises when my source observable is not of type void as shown here:
const obs = Observable.interval(1000);
After exploring different options, the two approaches I could think of for consuming the non-void observable are:
// Approach 1 (inefficient use of map)
consumer.consume(obs.map(() => {}));
// Approach 2 (confusing syntax)
consumer.consume(obs as any as Observable<void>);
What would be the most effective way to convert my observable to Observable<void>
in order to consume it properly?