mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-22 20:51:23 +00:00
Debounce gather refreshes
This commit is contained in:
parent
dd4c6ddafa
commit
90e6ff758a
1 changed files with 6 additions and 2 deletions
|
@ -24,9 +24,10 @@ var Server = require("./server");
|
|||
var Gather = require("./gather");
|
||||
var gather;
|
||||
var previousGather;
|
||||
var _ = require("lodash");
|
||||
|
||||
module.exports = function (namespace) {
|
||||
var refreshGather = function () {
|
||||
var refreshGather = _.debounce(function () {
|
||||
namespace.sockets.forEach(function (socket) {
|
||||
socket.emit("gather:refresh", {
|
||||
gather: gather.toJson(),
|
||||
|
@ -36,7 +37,10 @@ module.exports = function (namespace) {
|
|||
previousGather: previousGather
|
||||
});
|
||||
});
|
||||
};
|
||||
}, 200, {
|
||||
leading: true,
|
||||
trailing: true
|
||||
});
|
||||
|
||||
var newGather = function () {
|
||||
if (gather) previousGather = gather;
|
||||
|
|
Loading…
Reference in a new issue