1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-09-03 11:28:01 +00:00

Use the wiki event mechanism to dispatch lazyLoad notifications to syncers

We're trying to get to the point where wiki.js doesn't know about
syncers
This commit is contained in:
Jeremy Ruston
2013-03-16 10:50:36 +00:00
parent c3b57507b0
commit 854e8d7083
2 changed files with 7 additions and 3 deletions

View File

@@ -628,8 +628,8 @@ exports.getTiddlerText = function(title,defaultText) {
// Just return the text if we've got it
return tiddler.fields.text;
} else {
// Ask all the syncers to load the tiddler if they can
this.invokeSyncers("lazyLoad",title,tiddler);
// Tell any listeners about the need to lazily load this tiddler
this.dispatchEvent("lazyLoad",title);
// Indicate that the text is being loaded
return null;
}

View File

@@ -89,6 +89,10 @@ var TiddlyWebSyncer = function(options) {
this.wiki.addEventListener("change",function(changes) {
self.syncToServer(changes);
});
// Listen out for lazyLoad events
this.wiki.addEventListener("lazyLoad",function(title) {
self.lazyLoad(title);
});
this.log("Initialising with host:",this.host);
// Get the login status
this.getStatus(function (err,isLoggedIn,json) {
@@ -126,7 +130,7 @@ TiddlyWebSyncer.prototype.log = function(/* arguments */) {
/*
Lazily load a skinny tiddler if we can
*/
TiddlyWebSyncer.prototype.lazyLoad = function(title,tiddler) {
TiddlyWebSyncer.prototype.lazyLoad = function(title) {
// Queue up a sync task to load this tiddler
this.enqueueSyncTask({
type: "load",