Câu hỏi phỏng vấn Angular
Câu hỏi

What is Subscribing?

Câu trả lời

In the context of Angular and its use of RxJS (Reactive Extensions for JavaScript), "subscribing" refers to the process of an observer connecting to an observable to receive data. An observable is a data source that emits values over time, and it only starts emitting these values when an observer subscribes to it. The subscription creates a link between the observable and the observer, allowing the observer to receive notifications about the data being emitted.

When you subscribe to an observable, you typically provide an observer object. This observer object is a set of callback functions that define how to handle the data (or values), errors, and completion signals from the observable. For example, the observer object might include methods like next to handle incoming data, error to handle any errors, and complete to perform actions when the observable completes its data stream.

Here is a basic example of subscribing to an observable:

javascript Copy
import { Observable } from 'rxjs';

const observable = new Observable(subscriber => {
  subscriber.next('Hello');
  subscriber.next('World...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

How to inject base href ?

middle

Explain the difference between Constructor and ngOnInit

senior

When does a lazy loaded module is loaded?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào