Is it possible to make TiddlyFox asynchronous?

33 views
Skip to first unread message

Yakov

unread,
Oct 24, 2016, 5:08:09 AM10/24/16
to TiddlyWikiDev
Hi guys,

recently I've understood that the "slow saving" of big TiddlyWikis (Classic, in my case) is due to the synchronous nature of saving which makes the interface to hang while the saving is done. So I've tried implementing async saving with MicroTiddlyServer (current dev snapshot attached) and was very satisfied with the result. For now, I can't use MTS with all my TWs because of couple of reasons and it's not that popular anyway, so I'm curious if it's possible to make TiddlyFox async. I've tried some silly tricks like setTimeout("mozillaSaveFile(...)" but haven't succeeded. Looking at the code, I guess that can't work that way since mozillaSaveFile does stuff with DOM which can't be async:

function (path,content) {
    // Find the message box element
    var messageBox = document.getElementById("tiddlyfox-message-box");
    if(messageBox) {
        // Create the message element and put it in the message box
        var message = document.createElement("div");
        message.setAttribute("data-tiddlyfox-path",path);
        message.setAttribute("data-tiddlyfox-content",content);
        messageBox.appendChild(message);
        // Create and dispatch the custom event to the extension
        var event = document.createEvent("Events");
        event.initEvent("tiddlyfox-save-file",true,false);
        message.dispatchEvent(event);
    }
    return true;
}


As I'm not familiar with the internals of TiddlyFox, I wonder if this can be remade async (which would be very nice!) There's one thing to be aware of, though: 2 saving requests shouldn't go with a little delay -- or TF should prevent possible read/write [of same file] conflicts.

Best regards,
Yakov.
MicroTiddlyServer (YLv1.4.3'').php
Reply all
Reply to author
Forward
0 new messages