Hello Brian,

El miércoles, 24 de agosto de 2016, 4:31:51 (UTC+2), Brian Theado escribió:
>
> That was news to me. Thanks for explaining it so clearly.
>>
>
You're welcome!
 

>
> I now have some evidence there is more to the story than what you 
> explained. I was stepping through the code in the debugger to help me learn 
> about the syncadapter functionality in general and the pouchdb adapter in 
> particular. I had a breakpoint set in PouchAdaptor.prototype.loadTiddler 
> and when I hit the save button, I saw the load tiddler was triggered for 
> every tiddler I had stored in pouchdb. Even the ones which were not open 
> and I hadn't opened. But before the asynchronous loading could take place, 
> I saw the html file appear in the downloads status bar at the bottom of my 
> chrome window. I guessed that the tiddlers got loaded, but only after the 
> download file was generated. And I figured if they all loaded, then if I 
> hit the save button a second time, then the download would this time 
> contain the bodies of the tiddlers. I did a diff of the first download 
> against the second and found that I was right!
>

Very good catch! You have spotted a very interesting behavior. That happens 
because the lazy-loading mechanism is asynchronous, and the save mechanism 
is synchronous. When you click save the saver selects a template 
($:/core/saveAll in this case) and tries to render it. Rendering the 
template triggers the lazy-loading mechanism for all the tiddlers, but 
because the synchronous nature of the rendering mechanism it does not waits 
the lazy-loading mechanism to complete and triggers the download with the 
available data at that moment. The lazy-loading mechanism continues working 
in the background and eventually completes, that's why when you click the 
saving button a second time you get a complete wiki with all the tiddlers.



If I'm not missing anything, then a full download can be had by clicking 
> save, then waiting long enough for the tiddler bodies to be asynchronously 
> loaded, then clicking save again. Not the most user friendly, but it seems 
> to work.

 
Yes, that is definitely a workaround, but there is no way (currently) to 
know how long you have to wait. It can vary from the order of milliseconds 
to a couple of seconds, depending on the database size. To be honest, 
probably waiting a second will be enough for 99% of the times.


Here's how you can duplicate my test:
>
>    1. open a new noteself database instance
>    2. create a few tiddlers with some body text
>    3. close all tiddlers
>    4. refresh the page (no open tiddlers = no tiddler body loading)
>    5. click the save button
>    6. look in the console for the "PouchAdaptor: Retrieving tiddler" 
>    message
>    7. click the save button a 2nd time
>    8. compare the two html files, noticing that the 2nd one has the 
>    tiddler bodies and the first does not.
>
> Brian
>

Thank you very much for your report Brian. I will think in ways around 
this. I have opened a bug on Tiddlywiki repository:

https://github.com/Jermolene/TiddlyWiki5/issues/2552

 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8b2f9165-43df-47b2-ad42-7b028988184d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to