Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to check if an observable is of NEVER type?

I have a case in my angular application where I need to change the observable if the initial value was NEVER:

export class MyComponent {
  @Input() isInitiallyOpen$?: Observable<boolean> = NEVER;

  constructor(private myService: MyService) {
    this.isOpen$ = this.isInitiallyOpen$ ?? this.myService.isOpen$; // NOT WORKING
    // this.isOpen$ = NEVER at this point, and not this.myService.isOpen$
  }
}

I know that rxjs's NEVER is basically new Observable<never>(noop()). But my question is, is there any way to know that isInitiallyOpen$ stream is actually holding a NEVER value?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you check the NEVER Observable at the GitHub project you can see that its basically an empty Observable with a noop function:

export const NEVER = new Observable<never>(noop)

Therefore you can check if the variable equals NEVER. Below I made some tests for you to work with.

const { NEVER, Observable, noop } = rxjs;

const foo$ = NEVER
const bar$ = NEVER

console.log("foo$ === bar$: ", foo$ === bar$) // true
console.log("foo$ === NEVER: ", foo$ === NEVER) // true
console.log("foo$ === Observable: ", foo$ === Observable) // false
console.log("foo$ === new Observable(): ", foo$ === new Observable()) // false
console.log("foo$ === Observable(() => {}): ", foo$ === new Observable(() => {})) // false
console.log("foo$ === Observable(noop): ", foo$ === new Observable(noop)) // false
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/7.4.0/rxjs.umd.min.js"></script>

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!