尝试在 Pusher 客户端脚本中添加延迟时不起作用
when trying to add delay in Pusher client script it do not work
我试图为 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 });
}
但它正常工作
谢谢
试试这个:
channel.bind('fileUploadJob', function(data) {
setTimeout(function() { showMessage(data) }, 3000);
});
参考:
link 会告诉你实际发生了什么。
我试图为 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 });
}
但它正常工作
谢谢
试试这个:
channel.bind('fileUploadJob', function(data) {
setTimeout(function() { showMessage(data) }, 3000);
});
参考: link 会告诉你实际发生了什么。