In this blog, I'm going to explore the use of RxJS operators. As a beginner developer, we hear a lot about Promise/Observables/Subscription to call asynchronous services and perform data operations using traditional means, such as - loops, custom property mapper, and class models and so on. Instead, we can use various RxJS operators which are very easy and simple to write. In this blog, I will be demonstrating some of the real-time use cases of our day to day work and handling complex response in an easy way.
of() is used for converting the string/objects to Observables.
- ngOnInit() {
-
- const employee = {
- name: 'Rajendra'
- };
- const obsEmployee: Observable<any> = of(employee);
- obsEmployee.subscribe((data) => { console.log(data); });
-
- }