NGRX商店运行时检查NGZONE在Android上失败
我们在网上和离线窗口事件中实现了网络检查作为副作用。
online$ = createEffect(() => {
return fromEvent(window, 'online').pipe(mapTo(NetworkActions.deviceOnline()));
});
这在桌面Chrome和iOS Safari上正常工作,但是某种程度上会导致strictactionWithInngzone
在Android上检查运行时:
{
"state": {
"keyboard": {
"isKeyboardOpen": false
},
"network": {
"isDeviceOnline": true
}
},
"error": "Error: Action '[Network] Device Online' running outside NgZone. https://ngrx.io/guide/store/configuration/runtime-checks#strictactionwithinngzone"
},
是否有人知道为什么这仅在Android中发生?
编辑: 据我所知,fromevent(窗口,'...')应该始终在区域内,因为Zone.js确实修补了所有浏览器EventTarget。
此外,这也是在一个离子 + Cordova应用程序上,但仅在基于Android上时。我可以看到的唯一原因可能是在网络视图中运行的差异,但除此之外,它只是基本的rxjs,而Angular,
谢谢Pascal
We implemented a network check as a side effect with window event online and offline.
online$ = createEffect(() => {
return fromEvent(window, 'online').pipe(mapTo(NetworkActions.deviceOnline()));
});
This works fine in Desktop Chrome and on iOS Safari but somehow results in a strictActionWithinNgZone
runtime check on Android:
{
"state": {
"keyboard": {
"isKeyboardOpen": false
},
"network": {
"isDeviceOnline": true
}
},
"error": "Error: Action '[Network] Device Online' running outside NgZone. https://ngrx.io/guide/store/configuration/runtime-checks#strictactionwithinngzone"
},
Does anybody have any idea why this only happens in Android and why it even is a problem to begin with?
Edit:
As far as I understand it, fromEvent(window, '...') should always be inside the zone because zone.js does patch all Browser EventTarget.
Also this is on an Ionic + Cordova App but only when built on Android. Only reason I could see for the difference could be in the Webview it is running in but other than that it is just basic RxJS and Angular
Thanks Pascal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ionic + Cordova应用程序和Cordova网络插件 htttps:htttps:// ionicframework.com/docs/native/network
这似乎干扰了Android平台。如果没有插件,则不会发生错误,但是在线和离线窗口事件也永远不会在Android上开火。所以我想这与NGRX无关。
It looks like this was a super specific problem with an Ionic + Cordova App and the Cordova Network Plugin https://ionicframework.com/docs/native/network
This seems to interfere with the Android Platform. Without the Plugins the Error does not occur but the online and offline window events also never fire on Android. So I guess this has nothing to do with NgRx.