小编man*_*gdi的帖子

使用Firebase侦听器挂起浏览器更新数据表

我们使用firebase Listener进行更新UI,数据库结构如下:

在此输入图像描述

我们使用mailgun批量发送发送广播,因此一个广播可能有n个联系人(电子邮件),它可能有300个或可能有1000个联系人以及我们正在跟踪它的传递或读取或点击状态,因此每个联系人(电子邮件)将从mailgun回调中获取firebase数据库中的更新状态(使用firebase云功能)并更新它的状态和日期和时间.它将更新firebase数据库,因此我们将在此处获取使用firebase侦听器更新广播的通知.

现在我们正在更新dataTable,如果选择了广播,并且更新浏览器将要挂起,因为我们当时可以从mailGun获得100或300回调(取决于mailgun回调,他们将一次发送多少回调).对于UI,请检查下面的图像.

在此输入图像描述

更新dataTable浏览器时会挂起并且没有响应.

我们使用下面的代码:

var broadcastRef = firebase.database().ref("businessListings/" + listingId + "/broadcast");
broadcastRef.on('child_changed', function(broadcastSnapshot) {//it will call multiple time because when we received callback from mailgun at that time database will be update and we will received notification in Listener , it will get notification may be 100 or 300 at a time depends firebase database update from the mailgun.
        if (broadcastSnapshot.exists()) {
            var broadcastKey  = broadcastSnapshot.key;
            var broadcastResult = broadcastSnapshot.val();
            var activeMainTab = $('#mainTabBar li').find('a.active').html();
            allBroadCast[broadcastKey] = …
Run Code Online (Sandbox Code Playgroud)

javascript datatables firebase firebase-realtime-database

5
推荐指数
0
解决办法
134
查看次数