Angular Concepts

In this blog post, we have discussed some JavaScript and Angular concepts.

What is the difference between synchronous and asynchronous approach in programming?

In synchronous approach, the next statement will not be executed until the completion of the previous statement. Whereas, in asynchronous approach, the next statement will not wait for the completion of the previous statement.

What is observable?

An observable is a declarative function which can be subscribed to take actions on the received results. The observables are/can be:

  • Declarative i.e. they are executed only when they are subscribed
  • Unsubscribed as well
  • Used for asynchronous processing of statements
  • Angular uses RxJS library for observables

What is a Promise in JavaScript?

A promise object can return values in an asynchronous way. A promise maybe in 1 of the 3 states: fulfilled, rejected or pending. Promises are executed at the same time when they are created.

What is the Difference between Observable and Promise?

  • Observable is declarative which means it’s executed only when subscribed whereas the promise is imperative which is executed as soon as it’s created.
  • Observables provide many values whereas the promises provide single value.
  • Observables are cancellable whereas the promises are not.

What is ForkJoins?

Forkjoin is used to execute multiple promises (e.g. http requests) in parallel and returns a single array containing the response from each observable.

References:

Leave a Comment

Your email address will not be published.