import{MaybeObservable} from '/help/maybe-observable'
import{asObservable} from '/help/as-observable'
getGame$(catId: MaybeObservable<string>){
  return asObservable(catId).pipe(
    switchMap(id => of(this.getGame(id)))

// help/as-observable.ts
import{isObservable,of} from 'rxjs'
import{MaybeObservable} from './maybe-observable'
export function asObservable<T>(value: MaybeObservable<T>){
  return isObservable(value) ? value : of(value);

// help/maybe-observable.ts
import{Observable} from 'rxjs';
export type MaybeObservable<T> = T | Observable<T>;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter