I am trying to emit a custom object from my observable:
export class DataService {
private currentUserSource = new BehaviorSubject(new Employee());
currentUser = this.currentUserSource.asObservable();
constructor() { }
changeValue(user: Employee) {
this.currentUser.next(user)
}
}
If I understand correctly, then the next() method is used to emit a value to the observable stream. It works with strings and so and without an issue, but when I want to emit an object of type Employee then it fails with:
[ts] Property 'next' does not exist on type 'Observable<Employee>'. [2339]
So, how can I emit the object, when it's a custom class.
Here is the class, just for completion:
export class Employee {
login: String;
name: String;
firstName: String
active: boolean;
phone: String;
hourly: number;
SessionKey: String;
}
Comments
Post a Comment