How can I push data to tw in SyncAdapter

52 views
Skip to first unread message

LinOnetwo

unread,
Jan 22, 2020, 9:33:03 AM1/22/20
to TiddlyWikiDev
I'm continuing on my solid-syncadaptor, I'm considering only load skinnytiddlers on the first `getSkinnyTiddlers()` trigger.

And in the second trigger of `getSkinnyTiddlers()`, I load all the content of tiddlers at once, and put response into Cache API.

And in subsequent `getSkinnyTiddlers()`, I would use `stale-while-revalidate` strategy:
first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.

So I need to push data to tw:

1. `getSkinnyTiddlers()` need me to return all data at once, but I want to queue the request to the backend, and do it slowly
2. `stale-while-revalidate`'s `finally comes with the up-to-date data` need me push data to tw too.

Is there an API to do so?

Jeremy Ruston

unread,
Jan 22, 2020, 11:54:18 AM1/22/20
to TiddlyWikiDev
Hi LinOneTwo

To load a tiddler, your syncadaptor can call the $tw.syncer.storeTiddler(tiddlerFields) method with a hashmap of fields for the tiddler. You can call it asynchronously whenever you’ve got a new tiddler to load.

Best wishes

Jeremy.

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/363979a2-0f47-46a6-a4bf-fefbe9c01a0e%40googlegroups.com.

LinOnetwo

unread,
Jan 23, 2020, 1:25:48 AM1/23/20
to TiddlyWikiDev
Thank you! That really works, speed up the content loading.

I guess I can do same thing to `getSkinnyTiddlers()`, so skinny tiddlers can be loaded in the async way.

在 2020年1月23日星期四 UTC+8上午12:54:18,Jeremy Ruston写道:
Hi LinOneTwo

To load a tiddler, your syncadaptor can call the $tw.syncer.storeTiddler(tiddlerFields) method with a hashmap of fields for the tiddler. You can call it asynchronously whenever you’ve got a new tiddler to load.

Best wishes

Jeremy.
I'm continuing on my solid-syncadaptor, I'm considering only load skinnytiddlers on the first `getSkinnyTiddlers()` trigger.

And in the second trigger of `getSkinnyTiddlers()`, I load all the content of tiddlers at once, and put response into Cache API.

And in subsequent `getSkinnyTiddlers()`, I would use `stale-while-revalidate` strategy:
first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.

So I need to push data to tw:

1. `getSkinnyTiddlers()` need me to return all data at once, but I want to queue the request to the backend, and do it slowly
2. `stale-while-revalidate`'s `finally comes with the up-to-date data` need me push data to tw too.

Is there an API to do so?

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddly...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages