Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: create is deprecated: use new Observable() instead

I recently updated my version of angular using ng update and when running ng lint

I am getting the error create is deprecated: use new Observable() instead

this.data$ = Observable.create(t => {     t.next(this.model);     t.complete(); }); 

What is the syntax for new observable?

like image 887
mruanova Avatar asked Apr 05 '19 15:04

mruanova


People also ask

Is Observable create deprecated?

Angular: create is deprecated: use new Observable() instead. New!

Is Observable lazy?

Observables are "lazy", meaning if no one is listening, nothing happens.

Why Observable is used in Angular?

Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example: The HTTP module uses observables to handle AJAX requests and responses. The Router and Forms modules use observables to listen for and respond to user-input events.


Video Answer


1 Answers

Pretty simple

this.data$ = new Observable((observer: Observer) => {   observer.next();   observer.complete(); }); 
like image 115
Sergey Avatar answered Oct 11 '22 00:10

Sergey