Prev Next

Web / RxJs Interview questions

1. What is the full form of RxJS?

RxJS stands for Reactive Extension for JavaScript. RxJS is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code.

Read full answer

2. What is the purpose of RxJS?

RxJS handles asynchronous data streams. It helps you to write programs against async data streams easily.

Read full answer

3. What are observables and observers?

An Observable is basically a function that can return a stream of values to an observer over time, this can either be synchronously or asynchronously. The data values returned can go from zero to an infinite range of values. Observer executes some instructions when there is a new value or a chang...

Read full answer

4. How to unsubscribe in RXJS.

Get the subscription object when you subscribe and then call the unsubscribe method on the subscription object.

Read full answer

5. Types of observables.

There are 2 types of observables: hot and cold . The main difference is that a cold observable creates a data producer for each subscriber, whereas a hot observable creates a data producer first, and each subscriber gets the data from one producer, starting from the moment of subscription. A cold...

Read full answer

6. How to install RxJS?

use "npm install rxjs" command.

Read full answer

7. Difference between RXJS and Promise.

RXJS. Promise. Observable return stream of data. Promise return single value. You can subscribe and unsubscribe stream. You cannot cancel a promise. An Observable only starts if you subscribe to it. This is why Observables are called lazy. Promise starts immediately. Subscribe method is used for ...

Read full answer

8. In Angular, where did you use RXJS?

When you make some API calls using http clients returns Observables which we will subscribe to and get response/error.

Read full answer

9. Mention a few RXJS operators.

map transforms data in an Observable into different format. filter allow the data that meets condition/ restrict otherwise. merge operator will combine multiple Observables into one. If one of the observables emit a value the combined one will emit as well. concat only when observable completes, ...

Read full answer

10. Why is rxjs called Push/Reactive and NOT Pull/Imperative?

Imperative programming means that the listener code (Observer) is responsible to pull stream of data. Reactive programming means you register a callback and the stream is responsible to push data.

Read full answer

11. Explain Observer in RXJS.

Observer is an interface for a consumer of push-based notifications delivered by an Observable. It has below structure, interface Observer < T > { closed ? : boolean ; next : (value: T) => void ; error : (err: any) => void ; complete : () => void ; } A handler that implements the Observer interfa...

Read full answer

12. What are observable creation functions?

RxJS provides creation functions for the process of creating observables from promises, events, timers and even Ajax requests.

Read full answer

13. What is multicasting?

Multicasting is the practice of broadcasting to a list of multiple subscribers in a single execution.

Read full answer

14. What type are RXJS Observables? hot or cold?

In RxJS observables are cold, or unicast by default.

Read full answer

15. What is "tap" operator in RxJS?

The "tap" operator is used to perform side-effects for notifications from the source observable. Used when you want to affect outside the state with a notification without altering the notification. import { of } from 'rxjs' ; import { tap } from 'rxjs/operators' ; const source = of( 1 , 2 , 3 , ...

Read full answer

16. How do you perform error handling in observables?

You can handle errors by specifying an error callback on the observer instead of relying on try/catch which are ineffective in asynchronous environment. For example, you may define the error callback as below. myObservable.subscribe({next(num) {console.log("next value:" + num)}, error (err) {cons...

Read full answer

17. Explain the shorthand notation for subscribe method.

The subscribe() method can accept callback function definitions inline, for next, error and complete handlers is the short hand notation or subscribe method with positional arguments. For example, you can define subscribe method as below. myObservable.subscribe(num => console.log("next value:" + ...

Read full answer

«
»

Comments & Discussions