Top RxJS frequently asked interview questions.
What is RxJS
A:RxJS implements reactive extension for TypeScript and JavaScript. It is a combination of observer patter, iterator pattern and functional programming. It is a javascript library that brings the concept of "reactive programming" to the web. RxJS is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code. It is a standalone Javascript library that gives access to programmers to the Observable.
Q: What are the disadvantages of using RxJS?
A: The disadvantages are as follows -
- Debugging the code with observables is little difficult.
- As you start to use Observables, you can end up your full code wrapped under the observables.
A:The difference between BehaviourSubject and Observable -
Observable | BehaviourSubject |
---|---|
Observable is stateless | BehaviourSubject is stateful |
Observable creates copy of data | BehaviourSubject shares data |
Observable is unidirectional | BehaviourSubject is bidirectional |
A:The difference between Observables and Promises -
Promises | Observables |
---|---|
Promises runs asynchronously and we get the return value only once. | Observables runs asynchronously and we get the return value multiple times |
Promises are not lazy | Observables are lazy |
Promises cannot be cancelled | Observables can be cancelled |
Promises provide a single future value. | Observables provide multiple future values. |