1

In my Angular app I'm getting the error below only in aot build.

You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

and after debugging the ERROR saying is it's somewhere in the below codes

<ng-template #leftNavbar>
  <cust-sidebar name="navbar"
     [folded]="false"
     lockedOpen="gt-md"
     *ngIf="!conf.layout.navbar.hidden">
    <navbar class="left-navbar" [ngClass]="conf.layout.navbar.background" layout="vertical"></navbar>
  </cust-sidebar>
</ng-template>

and the ERROR also pointing to the the code below in ngOnInit of cust-sidebar

this._custConfigService.config
        .pipe(takeUntil(this._unsubscribeAll))
        .subscribe((config) => {
            this._conf = config;
        });

this is my config service code for getting and setting config

set config(value)
{ 
    let config = this._configSubject.getValue();

    config = _.merge({}, config, value); 
    this._configSubject.next(config);
}

get config(): any | Observable<any>
{
    return this._configSubject.asObservable();
}

what's wrong with my code and why I'm only getting it in --aot build not in normal build.

Check this answer

He is saying that he was having two different version of CLI and after changing the CLI version it worked for him, I also have two different version of CLI but that is not a problem I think?

Sabir Hossain
  • 1,183
  • 1
  • 25
  • 46

1 Answers1

1

I got the issue thanks, The error happened because I was importing the takeUntil from rxjs/internal/operators after I change the import to rxjs/operators the problem was solved.

Now I'm confused, if one import is working in development it also should work in production otherwise angular should stick to one import file instead making people confuse.

Sabir Hossain
  • 1,183
  • 1
  • 25
  • 46
  • Oh, great! Great catch! How did you figure out that you should change import address? – StepUp Dec 07 '19 at 21:45
  • 1
    I got the same error in another page, and removed all old code from there and after adding new code the VS automatically imported the takeUntil from the working import, then I checked all the code in given problem and found the import was different. – Sabir Hossain Dec 08 '19 at 12:41