Google cloud firestore Firestore emulator-模拟连接丢失

Google cloud firestore Firestore emulator-模拟连接丢失,google-cloud-firestore,Google Cloud Firestore,我有一个带有实时侦听器设置的应用程序,可以立即获取收藏中的所有更新。我也有一些逻辑来选择丢失的文档,以防我的应用程序失去连接(在这种情况下,侦听器会丢失一些文档) 我想用模拟器来测试这个逻辑,但是如何模拟连接的丢失呢?有内置的功能吗?实际上,下面介绍了如何进行一般操作,无论是使用模拟器还是实际的Firestore实例: firebase.firestore().disableNetwork() .then(() => { // Do offline actions

我有一个带有实时侦听器设置的应用程序,可以立即获取收藏中的所有更新。我也有一些逻辑来选择丢失的文档,以防我的应用程序失去连接(在这种情况下,侦听器会丢失一些文档)

我想用模拟器来测试这个逻辑,但是如何模拟连接的丢失呢?有内置的功能吗?

实际上,下面介绍了如何进行一般操作,无论是使用模拟器还是实际的Firestore实例:

firebase.firestore().disableNetwork()
    .then(() => {
        // Do offline actions
        // ...
    });

firebase.firestore().enableNetwork()
    .then(() => {
        // Do online actions
        // ...
    });
实际上,以下说明了如何进行一般操作,无论是使用emulator还是实际的Firestore实例:

firebase.firestore().disableNetwork()
    .then(() => {
        // Do offline actions
        // ...
    });

firebase.firestore().enableNetwork()
    .then(() => {
        // Do online actions
        // ...
    });