Rejigging syncer structuring

The goal is to separate out the saver handling from the syncadaptor
handling; it will take a few steps to get there
This commit is contained in:
Jermolene
2014-08-14 11:12:25 +01:00
parent 82860aea33
commit 27f1f82a70
5 changed files with 40 additions and 28 deletions
+10 -1
View File
@@ -62,8 +62,17 @@ exports.startup = function() {
document: document
});
}
// Find a working syncadaptor
$tw.syncadaptor = undefined;
$tw.modules.forEachModuleOfType("syncadaptor",function(title,module) {
if(!$tw.syncadaptor && module.adaptorClass) {
$tw.syncadaptor = new module.adaptorClass({wiki: $tw.wiki});
}
});
// Set up the syncer object
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
if($tw.syncadaptor) {
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki, syncadaptor: $tw.syncadaptor});
}
// Host-specific startup
if($tw.browser) {
// Install the popup manager
+4 -7
View File
@@ -14,20 +14,15 @@ The syncer tracks changes to the store. If a syncadaptor is used then individual
/*
Instantiate the syncer with the following options:
syncadaptor: reference to syncadaptor to be used
wiki: wiki to be synced
*/
function Syncer(options) {
var self = this;
this.wiki = options.wiki;
this.syncadaptor = options.syncadaptor
// Make a logger
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : ""));
// Find a working syncadaptor
this.syncadaptor = undefined;
$tw.modules.forEachModuleOfType("syncadaptor",function(title,module) {
if(!self.syncadaptor && module.adaptorClass) {
self.syncadaptor = new module.adaptorClass(self);
}
});
// Initialise our savers
if($tw.browser) {
this.initSavers();
@@ -603,6 +598,8 @@ Syncer.prototype.dispatchTask = function(task,callback) {
}
// Invoke the callback
callback(null);
},{
tiddlerInfo: self.tiddlerInfo[task.title]
});
}
};