What is the difference between Promises and Observables?

后端 未结 30 2663
小鲜肉
小鲜肉 2020-11-21 23:48

What is the difference between Promise and Observable in Angular?

An example on each would be helpful in understanding both the cases. In w

30条回答
  •  不思量自难忘°
    2020-11-22 00:32

    1. Promises are focused only for single values or resolves, observables are stream of data.

    2. Observables can be canceled but promises can't be canceled.

    The least known one, atleast to me is

    1. Promises are always of asynchronous nature, but observables can be both synchronous and asynchronous.

提交回复
热议问题