当试图在Pusher客户端脚本中添加延迟时,它不起作用

时间:2017-04-27 06:51:21

标签: pusher

我试图在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 });

            }

但它只是正常工作

谢谢

1 个答案:

答案 0 :(得分:3)

试试这个:

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

参考:https://stackoverflow.com/a/3800526/3475350 这个链接会告诉你实际发生了什么。

相关问题