简体   繁体   English

Angular 7 rxjs/forkJoin :您在需要流的地方提供了“未定义”。 你可以提供一个 Observable、Promise、Array 或 Iterable

[英]Angular 7 rxjs/forkJoin : You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable

logic component.js file in below.下面的逻辑 component.js 文件。

ngOnInit() {  
   const join= forkJoin( this.getReconciliationData()); //import { forkJoin } from 'rxjs/internal/observable/forkJoin';
   const subscribe= join.subscribe(result=>this.setReferenceTableData()); //Getting issue here
  }
  getReconciliationData() {
    this.commonService.getMasterData(MaterDataType.LOCALREFERENCES).subscribe(result=>{
      this.categories=result;
      this.categories.forEach(c => {
        c.children.forEach(subC => {
          this.references.push(...subC.references);
        });
        this.subCategories.push(...c.children);
      });
    });

  }
  setReferenceTableData=function(){
    this.dataSource=new MatTableDataSource(this.references);
  }

While execution time getting an error.执行时出错。

***core.js:7187 ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
    at Object.push../node_modules/rxjs/internal/util/subscribeTo.js.exports.subscribeTo (subscribeTo.js:29)
    at Object.from (from.js:11)
    at _loop_1 (forkJoin.js:42)
    at Observable._subscribe (forkJoin.js:67)
    at Observable.push../node_modules/rxjs/internal/Observable.js.Observable._trySubscribe (Observable.js:44)
    at Observable.push../node_modules/rxjs/internal/Observable.js.Observable.subscribe (Observable.js:30)
    at MedicalfileInternalServiceModelComponent.ngOnInit (medicalfile-internal-service-model.component.ts:69)
    at checkAndUpdateDirectiveInline (core.js:24503)
    at checkAndUpdateNodeInline (core.js:35163)
    at checkAndUpdateNode (core.js:35102).***

. . I Think here looking return object from getReconciliationData() function.我认为这里从 getReconciliationData() 函数寻找返回对象。 But in my case not required return statement.但在我的情况下不需要 return 语句。 Anyone please help us for this issue.任何人请帮助我们解决这个问题。 I need to one by one function execution.我需要一一执行功能。

forkJoin expects array. forkJoin需要数组。

Try like this:像这样尝试:

const join= forkJoin( [this.getReconciliationData()])

Try like below modified code .尝试如下修改后的代码。 And i don't think you need forkJoin since you have only one observable而且我认为你不需要 forkJoin 因为你只有一个可观察的

  ngOnInit() {
    const subscribe = this.getReconciliationData().subscribe(result => {
      this.categories = result;
      this.categories.forEach(c => {
        c.children.forEach(subC => {
          this.references.push(...subC.references);
        });
        this.subCategories.push(...c.children);
      });
      this.setReferenceTableData();
    }
  };

  getReconciliationData(): Observable<any> {
    return this.commonService.getMasterData(MaterDataType.LOCALREFERENCES);

  }
  setReferenceTableData=function(){
    this.dataSource=new MatTableDataSource(this.references);
  }

Your getReconciliationData() method returns nothing and it should return an Observable which you want to pass to the forkJoin() method.你的getReconciliationData()方法什么都不返回,它应该返回一个你想传递给forkJoin()方法的Observable But are you sure you need to use it when you have only one thing to subscribe to?但是,当您只有一件事要订阅时,您确定需要使用它吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rxjs 6:使用catchError()可以为您提供“未定义”的预期流。 您可以提供一个Observable,Promise,Array或Iterable - Rxjs 6: using catchError() gives You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable 您提供了“未定义”的预期流。 您可以提供一个Observable,Promise,Array或Iterable - You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable 类型错误:您在需要流的地方提供了“未定义”。 你可以提供一个 Observable、Promise、Array 或 Iterable - TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable Angular:您在需要流的地方提供了一个无效的对象。 你可以提供一个 Observable、Promise、Array 或 Iterable - Angular: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable Angular5:TypeError:您提供了&#39;undefined&#39;,其中包含一个流。 您可以提供Observable,Promise,Array或Iterable - Angular5 : TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable TypeError:您在需要 stream 的地方提供了“未定义”。 部署angular时可以提供Observable、Promise、Array或Iterable - TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable when deploying angular 错误类型错误:您在需要流的地方提供了“未定义”。 您可以在 Angular 服务中提供 Observable、Promise、Array 或 Iterable - ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable in Angular Services 类型错误:您提供了一个预期流的无效对象。 你可以提供一个 Observable、Promise、Array 或 Iterable - TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable xplat您提供了一个无效的对象,该对象应在其中流。 您可以提供一个Observable,Promise,Array或Iterable - xplat You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable 错误类型错误:您在需要流的地方提供了“空”。 你可以提供一个 Observable、Promise、Array 或 Iterable - ERROR TypeError: You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM