what is observable in angular? promise vs observable.

  • Promise is active, whereas observable is lazy.  It means promise completes its next task till response comes. whereas observable do nothing and waits for the response.
  • Promise is always asynchronous(start to run next code till response), whereas an Observable is default synchronous(don't run next code and wait for response) but you can make it asynchronous(you can forcefully make it asynchronous).
  • Promise provide values only one time when you call the service. but Observable can continuously send value(notifications) on on fix time interval. for that you will have to set interval using "setInterval" function.     


Comments

Popular posts from this blog

how to save images with angular nodejs

How to restrict your logged In page in angular (authentication guard)

How to notify about data update to other component.