Observables allow multiple listeners and can emit multiple values that can be manipulated using different operations such as map or filter (you can read more about it at the RxJS github page ). If you are unfamiliar with Promises, make sure to check out “A quick guide to JavaScript Promises”. Observables work similarly to Promises asynchronous types that emit values pushed to them by another function. We also used the Observable type and async pipe inside template. After that it will be automatically (almost magically) injected into our component and we will be able to reuse it later (this mechanism works similar to auto-injection in the Spring Framework). Angular will look for a class of this type and instantiate a singleton for us. If you take close look at the constructor you will see a parameter of type EchoService. Additionally, we introduced the concept of Dependency Injection.
0 Comments
Leave a Reply. |