I have the following code
this.form.valueChanges.pipe(
take(1),
map(val => // doSomething),
exhaustMap(val =>
// someInner observable logic
return of({someValue})
)
).subscribe(finalVal => doSomething());
Now this code in the exhaustMap is repeated in several components and I'd like to extract it as an external function.
I have tried the following
myExhaust(obs: Observable<any>): Observable<{ someValue: SomeClass }> {
return obs.pipe(
exhaustMap((val) => {
// do some stuff
return of({someValue})
})
);
}
But then I dont know how to plug it in the original code (that if the function code itself is correct)