【问题标题】:when trying to add delay in Pusher client script it do not work当尝试在 Pusher 客户端脚本中添加延迟时,它不起作用
【发布时间】:2017-04-27 06:51:20
【问题描述】:

我试图在 Pusher 中为响应添加一些延迟

代码

Pusher.logToConsole = true;
            var message;
            var pusher = new Pusher('someKeykjhkjklhl', {
              cluster: 'eu',
              encrypted: true
            });

            var channel = pusher.subscribe('my-channel');
            channel.bind('fileUploadJob', function(data) {
                 setTimeout(showMessage(data), 3000);

            });

            function showMessage(data)
            {
                    toastr.success(data.message,{ fadeAway: 1000 });

            }

但它就像正常工作一样

谢谢

【问题讨论】:

    标签: pusher


    【解决方案1】:

    试试这个:

    channel.bind('fileUploadJob', function(data) {
        setTimeout(function() { showMessage(data) }, 3000);
    });
    

    参考:https://stackoverflow.com/a/3800526/3475350 此链接将告诉您实际发生的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多