Thanks for the question, Cesar!
Unfortunately, it's not enough, because tap executes callback only when observable emit new data, so in that case, we will set a true flag when the request was already completed. That's why I used defer operator which evaluates callback when the user subscribes to observable.
Otherwise, you can write something like this:
return of(null).pipe(
tap(() => setloading(true)),
switchMap(() => fnReturnValue),
finalize(() => setloading(false)),
);
But honestly, I don't like this solution, because we have to use another observable here and I don't think that this approach is the right choice :)