observable subscription does not work when written in ngOnit() in IE

落花浮王杯 提交于 2019-12-23 11:46:14

问题


I have defined a behavior subject:

component.ts

bsub1: BehaviorSubject<Array<any>> = new BehaviorSubject(null);

And called next() on it:

html:

<button (click) = getData()>Data</button>

component.ts:

getData() {
    getSomething(value, bsub1);
}

service.ts

getSomething(value, _observable) {
    //do something

    _observable.next(retun)
    somevariable.map(p => {
        return { "a": value1, "b": value2 }
    });
}

And made a subscription:

component.ts

 ngOnInit() {
     bsub1.subscribe(list=>{
         console.log("subscribed to bsub1")
     });
 }

But my code does not reach upto subscription after call to getSomething(). It reaches there when component loads but when next() is called after that it does not subscribe. this happen only in IE 11 whereas in edge, chrome and firefox it is working.

Can someone explain me this behavior?

来源:https://stackoverflow.com/questions/51673368/observable-subscription-does-not-work-when-written-in-ngonit-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!