我正在使用Pusher将Webhook更新发送到计时器。问题是,如果计时器是用过期的“ diff”构造的,则会收到“尝试在倒计时已为0时启动计时器”错误。另外,我无法正确设置stop回调以在新更新过期时重置计时器。有什么办法可以在FlipClock.js中处理 在语音提示中:
...
mounted() {
let remaining = moment.duration(moment(this.dbTime + '+0:00') - this.now);
this.clock = $('.clock').FlipClock(remaining/1000, {
clockFace: 'HourlyCounter',
countdown: true,
callbacks: {
stop: function() {
}
}
});
},
...
,并且在Pusher更新发生时出现在语音提示中:
...
created() {
let interval = this.refreshEverySecond();
var pusher = new Pusher('XXXXXXXXXX', {
cluster: 'us2',
forceTLS: true
});
// Subscribe to the channel we specified in our Laravel Event
var channel = pusher.subscribe('timer-channel');
var ref = this;
// Bind a function to a Event (the full Laravel class)
channel.bind('timer-updated.' + this.timer_id, function(data) {
ref.dbTime = data.end_time;
ref.db_is_locked = data.is_locked
ref.update_clock();
});
},
....
update_clock方法:
update_clock() {
let remaining = moment.duration(moment(this.dbTime + '+0:00') - this.now);
this.clock.reset();
this.clock.setTime(remaining/1000);
return this.clock.start();
},