嗨,我是新手。
我不知道为什么无法在Observable中设置新值
我的代码:
resultJob: Observable<any> = Observable.of("PENDING");
ngOnInit() {
this.resultJob.subscribe(result => {
result.next("SUCCESS")
result.complete()
})
}
Run Code Online (Sandbox Code Playgroud)
此代码返回 result.next is not a function
Let's say I have a model User.
I want to create a BehaviorSubject of type User as below:
private userSource = new BehaviorSubject<User>({});
Run Code Online (Sandbox Code Playgroud)
With this statement I'm getting the following error:
Argument of type '{}' is not assignable to parameter of type 'User'
Run Code Online (Sandbox Code Playgroud)
Could anyone help me how define a BehaviorSubject of type User