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

224
Views
¿Cómo verificar si un observable es de tipo NUNCA?

Tengo un caso en mi aplicación angular donde necesito cambiar el observable si el valor inicial NEVER fue:

 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$ } }

Sé que rxjs NEVER es básicamente new Observable<never>(noop()) . Pero mi pregunta es, ¿hay alguna manera de saber que el flujo isInitiallyOpen$ realmente tiene un valor NEVER ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si marca NEVER Observable en el proyecto GitHub, puede ver que es básicamente un Observable vacío con una función noop:

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

Por lo tanto, puede verificar si la variable es igual a NEVER . A continuación hice algunas pruebas para que usted pueda trabajar con ellas.

 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!