updated by GasGit automation
This commit is contained in:
parent
8974faf1bc
commit
e4c56d30d8
1 changed files with 107 additions and 97 deletions
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* simulate Watcher with apps script
|
* simulate Watcher with apps script
|
||||||
* various changes server side can be watched for server side
|
* various changes server side can be watched for server side
|
||||||
* and resolved client side
|
* and resolved client side
|
||||||
* @constructor ClientWatcher
|
* @constructor ClientWatcher
|
||||||
*/
|
*/
|
||||||
var ClientWatcher = (function (ns) {
|
var ClientWatcher = (function (ns) {
|
||||||
|
|
||||||
var watchers_ = {},startTime_=0, pack_;
|
var watchers_ = {},startTime_=0, pack_;
|
||||||
|
@ -37,6 +37,7 @@ var ClientWatcher = (function (ns) {
|
||||||
var watch = Utils.vanMerge ([{
|
var watch = Utils.vanMerge ([{
|
||||||
pollFrequency:2500, // if this is 0, then polling is not done, and it needs self.poke()
|
pollFrequency:2500, // if this is 0, then polling is not done, and it needs self.poke()
|
||||||
id: '' , // Watcher id
|
id: '' , // Watcher id
|
||||||
|
pollVisibleOnly:true, // just poll if the page is actually visible
|
||||||
watch: {
|
watch: {
|
||||||
active: true, // whether to watch for changes to active
|
active: true, // whether to watch for changes to active
|
||||||
data: true, // whether to watch for data content changes
|
data: true, // whether to watch for data content changes
|
||||||
|
@ -53,7 +54,8 @@ var ClientWatcher = (function (ns) {
|
||||||
range: "", // if range, specifiy a range to watch
|
range: "", // if range, specifiy a range to watch
|
||||||
sheet: "", // a sheet name - if not given, the active sheet will be used
|
sheet: "", // a sheet name - if not given, the active sheet will be used
|
||||||
property:"Values", // Values,Backgrounds etc...
|
property:"Values", // Values,Backgrounds etc...
|
||||||
fiddler:true // whether to create a fiddler to mnipulate data (ignored for nondata property)
|
fiddler:true, // whether to create a fiddler to mnipulate data (ignored for nondata property)
|
||||||
|
applyFilters:false // whether to apply filters
|
||||||
}
|
}
|
||||||
},options || {}]);
|
},options || {}]);
|
||||||
|
|
||||||
|
@ -119,7 +121,8 @@ var ClientWatcher = (function (ns) {
|
||||||
responded:0, // time responded
|
responded:0, // time responded
|
||||||
errors:0 , // number of errors
|
errors:0 , // number of errors
|
||||||
hits:0, // how many times a change was detected
|
hits:0, // how many times a change was detected
|
||||||
totalWaiting:0 // time spent waiting for server response
|
totalWaiting:0, // time spent waiting for server response
|
||||||
|
idle:0 // no of times we didnt bother polling
|
||||||
};
|
};
|
||||||
|
|
||||||
self.start = function () {
|
self.start = function () {
|
||||||
|
@ -252,10 +255,17 @@ var ClientWatcher = (function (ns) {
|
||||||
function pollWork () {
|
function pollWork () {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
// check for visibility.. if not visible, then don't bother polling
|
||||||
|
if (pack_ && watch_.pollVisibleOnly && !ifvisible.now() ) {
|
||||||
|
status_.idle++;
|
||||||
|
finallyActions();
|
||||||
|
resolve(pack_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
Provoke.run ("ServerWatcher", "poll", watch_)
|
Provoke.run ("ServerWatcher", "poll", watch_)
|
||||||
.then (
|
.then (
|
||||||
function (pack) {
|
function (pack) {
|
||||||
|
|
||||||
// save this for interest
|
// save this for interest
|
||||||
pack_ = pack;
|
pack_ = pack;
|
||||||
current_.dataSource = pack_.dataSource;
|
current_.dataSource = pack_.dataSource;
|
||||||
|
@ -304,11 +314,11 @@ var ClientWatcher = (function (ns) {
|
||||||
// sometimes there will be network errors which can generally be ignored..
|
// sometimes there will be network errors which can generally be ignored..
|
||||||
rejectActions (reject, err);
|
rejectActions (reject, err);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return ns;
|
return ns;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue