Dibas
Dibas

Reputation: 1

node_modules has no exported member 'BehaviorSubject'

import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';

@Injectable({ providedIn: 'root' }) export class DataService {

private goals = new BehaviorSubject(['The initial goal']); goal = this.goals.asObservable();

constructor() { }

}

I am unable run, as I am getting error as below in tooltip: [ts] Module '"c:/Users/Admin/free_project/code/ng5/node_modules/rxjs/BehaviorSubject"' has no exported member 'BehaviorSubject'.

Upvotes: 0

Views: 600

Answers (1)

ggradnig
ggradnig

Reputation: 14199

No, you shouldn't access rxjs/internal/BehaviorSubject.

The rule of thumb for RxJS 6 is:

Creation Functions (such as of, from, etc.) and Observable types (Observable, Subject, BehaviourSubject) are imported from rxjs:

import {BehaviourSubject} from "rxjs";

Operators (such as map, mergeMap, etc.) are imported from rxjs/operators:

import {map} from "rxjs/operators";

Upvotes: 4

Related Questions