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

前端 未结 3 1273
长发绾君心
长发绾君心 2021-01-07 20:31

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

I am getting the error create is deprecated: use

3条回答
  •  一整个雨季
    2021-01-07 21:13

    observableSubscription: Subscription;
    

    Creating Custom Observable

    const observer = new Observable((observer: Observer) => {
       observer.next();
       observer.error();
       observer.complete();
    });
    

    Subscribing To Custom Observable

    this.observableSubscription = observer.subscribe((data:any) => {
       console.log(data);
    })
    

    Unsubscribing

    this.observableSubscription.unsubscribe();
    

提交回复
热议问题