简体   繁体   English

ionic4 / angular7 - 如何在意外的BLE中断上使用导航API?

[英]ionic4 / angular7 - How should one use the navigation API on unexpected BLE interrupts?

The code in development is running on both Android and iOS, the frameworks in use are Angular7 and ionic4 as well as the cordova BLE plugin. 开发中的代码在Android和iOS上运行,使用的框架是Angular7和ionic4以及cordova BLE插件。

After an unexpected connection failure, the app should navigate back to the root URL / home screen, which it does. 在意外的连接失败后,应用程序应该导航回根URL /主屏幕,它会执行此操作。 But afterwards it is not possible to navigate away from the home screen and the application is stuck. 但之后无法离开主屏幕并且应用程序卡住了。

I've so far ascertained that a navigation event is indeed fired and that the underlying BLE plugin does still work and establish a new connection when trying to reconnect. 到目前为止,我确定导航事件确实被触发,并且底层BLE插件在尝试重新连接时仍然可以工作并建立新连接。

According to the Google Chrome developer tools, the DOM is clear of any remaining pages, as would be expected. 根据谷歌Chrome开发人员工具,DOM可以清除任何剩余的页面,如预期的那样。

Also, I've ascertained that any services holding a global state are completely reset. 此外,我已确定任何持有全局状态的服务都已完全重置。

I've tried updating angular and ionic to the latest version, but it does not make a difference. 我已经尝试将角度和离子更新到最新版本,但它没有任何区别。

This code snippet is called as a callback to the (click)-Event from some s 这段代码被称为对某些s的(click)-Event的回调

this.communicatorService.connect(device).subscribe(
            peripheral => {
                console.debug('CONNECTED');
                this.zone.run(() => {
                    this.navCtrl.navigateForward('/connected').then(
                        _ => console.debug('NAVIGATED')
                    );
                });
            },
            error => {
                console.error(error);
                this.resetState();
                this.zone.run(() => {
                    this.navCtrl.navigateBack('/').then(
                        _ => console.debug('NAVIGATED BACK')
                    )
                });
            }
        );

What I expect would be to read CONNECTED and NAVIGATED on the console and then witness a page transition. 我期望在控制台上读取CONNECTED和NAVIGATED,然后见证页面转换。

This is only the case before the app experiences an unexpected BLE connection loss. 这只是应用程序遇到意外的BLE连接丢失之前的情况。

After a connection loss I can read 'NAVIGATED BACK' on the console. 连接丢失后,我可以在控制台上阅读“NAVIGATED BACK”。 When trying to reconnect to the BLE device, the code-snippet is executed and I can read CONNECTED and NAVIGATED, but no page transition occurs. 尝试重新连接到BLE设备时,会执行代码段,我可以读取CONNECTED和NAVIGATED,但不会发生页面转换。

Am I using the navigation API correctly in this case? 在这种情况下我是否正确使用导航API?

Found the error. 发现错误。 I had a blocking statement in a controller's ngOnDestroy-method. 我在控制器的ngOnDestroy方法中有一个阻塞语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM