Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度/rxjs可观测未捕获类型错误:无法读取属性';ISS&x27;未定义的 //示例1 const xd=新的可观测({next})=>{ 其次(“3”); }); 订阅(msg=>console.log(msg)); //例2 const obs$=新的可观测值(); obs$.subscribe(mg=>console.log(mg)); //例3 私有套接字:SocketIOClient.socket; 构造函数(私有url:string){ this.socket=io(this.url); } 听{ 返回新的可观察(({next})=>{ this.socket.on(“消息”,下一个) }) }_Angular_Typescript_Rxjs - Fatal编程技术网

Angular 角度/rxjs可观测未捕获类型错误:无法读取属性';ISS&x27;未定义的 //示例1 const xd=新的可观测({next})=>{ 其次(“3”); }); 订阅(msg=>console.log(msg)); //例2 const obs$=新的可观测值(); obs$.subscribe(mg=>console.log(mg)); //例3 私有套接字:SocketIOClient.socket; 构造函数(私有url:string){ this.socket=io(this.url); } 听{ 返回新的可观察(({next})=>{ this.socket.on(“消息”,下一个) }) }

Angular 角度/rxjs可观测未捕获类型错误:无法读取属性';ISS&x27;未定义的 //示例1 const xd=新的可观测({next})=>{ 其次(“3”); }); 订阅(msg=>console.log(msg)); //例2 const obs$=新的可观测值(); obs$.subscribe(mg=>console.log(mg)); //例3 私有套接字:SocketIOClient.socket; 构造函数(私有url:string){ this.socket=io(this.url); } 听{ 返回新的可观察(({next})=>{ this.socket.on(“消息”,下一个) }) },angular,typescript,rxjs,Angular,Typescript,Rxjs,他们都给了我同样的错误,可能出了什么问题 (未捕获的TypeError:无法读取未定义的属性“isStopped”)这样使用 const xd = new Observable((observer) => { // observable execution observer.next("3"); }); xd.subscribe(msg =>{ console.log(msg) }, (error)=>{ console.error(error); } );

他们都给了我同样的错误,可能出了什么问题

(未捕获的TypeError:无法读取未定义的属性“isStopped”)

这样使用

const xd = new Observable((observer) => {
  // observable execution
  observer.next("3");
});

xd.subscribe(msg =>{
   console.log(msg)
},
(error)=>{
  console.error(error);
}
);
像这样使用,

const xd = new Observable((observer) => {
  // observable execution
  observer.next("3");
});

xd.subscribe(msg =>{
   console.log(msg)
},
(error)=>{
  console.error(error);
}
);

我认为以这种方式创建可观察实例存在一些问题。你能试着回答这个问题吗。意思是说代替{next}=>使用here(observer)=>{observer.next(“3”)};如果提供的答案有效,则将其标记为接受,这将帮助面临相同问题的新手找到答案。干杯做了,我只是不知道如何在电话里做。ps:你应该更新你的答案,说在这种情况下,解构不起作用,让它一开始更清楚。我认为以这种方式创建可观察的实例存在一些问题。你能试着回答这个问题吗。意思是说代替{next}=>使用here(observer)=>{observer.next(“3”)};如果提供的答案有效,则将其标记为接受,这将帮助面临相同问题的新手找到答案。干杯做了,我只是不知道如何在电话里做。ps:你应该更新你的答案,说在这种情况下,解构不起作用,让第一眼就看清楚