when to use state tiddlers and when temp tiddlers

377 views
Skip to first unread message

Mohammad

unread,
Jan 8, 2020, 10:57:42 PM1/8/20
to TiddlyWiki
Tiddlywiki stores global variables in tiddler fields.

For example all state tiddlers in widgets like reveal, checkbox, edit-text, ...

Considering both single file wiki and Node.js wiki what are your recommendation in using

  • $:/temp/mytiddlers
  • $:/state/mytiddlers
--Mohammad

Eric Shulman

unread,
Jan 8, 2020, 11:30:58 PM1/8/20
to TiddlyWiki
Both $:/temp and $:/state are ignored when determining if the document is "dirty" (see $:/core/SaverFilter)... and by default both are saved when you save the file (except for $:/state/popup, which are NOT saved... see $:/core/save/all)

However, conceptually, $:/temp tiddlers should be "throw-away"... able to be discarded when not actually in use, while $:/state tiddlers should reasonably be expected to persist across sessions.

To enforce this difference, I routinely create a tiddler, tagged with $:/tags/Macro, containing:
\define publishFilter() -[prefix[$:/temp]]

This variable is automatically included by the $:/core/save/all filter.  The effect is that $:/temp tiddlers are NOT saved when you save the file and are, in effect, automatically discarded at the end of the session.

Thus, if I want a reveal state to always revert to closed on startup, I will use a $:/temp tiddler, but if I want the reveal state to persist across sessions, I will use a $:/state tiddler

-e


TonyM

unread,
Jan 9, 2020, 12:29:36 AM1/9/20
to TiddlyWiki
Eric,

Nice answer.
However did you mean $:/config/SaverFilter?
for detecting dirty?

The fact that the dirty indicator is different from what gets saved is a useful fact and possible trick.

Regards
Tony

Mohammad

unread,
Jan 9, 2020, 12:38:52 AM1/9/20
to TiddlyWiki
Added to TW-Scripts

Hi Eric!
 Quite useful information and WISH to have such explanation in tiddlywiki.com

--Mohammad

Eric Shulman

unread,
Jan 9, 2020, 12:52:11 AM1/9/20
to TiddlyWiki
On Wednesday, January 8, 2020 at 9:29:36 PM UTC-8, TonyM wrote:
However did you mean $:/config/SaverFilter?
for detecting dirty?

yeah... I meant to type $:/config/SaverFilter

-e

PMario

unread,
Jan 9, 2020, 2:01:21 AM1/9/20
to TiddlyWiki
On Thursday, January 9, 2020 at 6:38:52 AM UTC+1, Mohammad wrote:
Hi Eric!
 Quite useful information and WISH to have such explanation in tiddlywiki.com

Mohammad

unread,
Jan 9, 2020, 3:17:48 AM1/9/20
to TiddlyWiki
Good links Mario!

Thanks

Atronoush

unread,
Feb 5, 2020, 10:52:20 AM2/5/20
to tiddl...@googlegroups.com
I confused about this!

By dirty saving does it mean sync on node.js or pushing the save button and create a single file?

I use a tiddler with $:/state prefix to keep the status of a $reveal widget between two sessions and I use node.js
When I reload the wiki, I see TW has deleted all $:/state tiddlers, so I cannot keep the status!


This is the code I used to reproduce the issue

<$reveal type=match state="$:/state/tid" text="show" defualt=show>
State is exist and its value is //show//
</$reveal>
<$reveal type=nomatch state="$:/state/tid" text="show" defualt=show>
State tiddler is not exist or its value is //hide//
</$reveal>

<$button>
<$list filter="[[$:/state/tid]get[text]match[show]]" emptyMessage="""Show <$action-setfield $tiddler="$:/state/tid" text="show"/>""">
Hide <$action-setfield $tiddler="$:/state/tid" text="hide"/>
</$list>
</$button>

On node.js TW seems deletes $:/state tiddlers!

Thank in advance
Atronoush

On Thursday, January 9, 2020 at 8:00:58 AM UTC+3:30, Eric Shulman wrote:

Mohammad

unread,
Feb 5, 2020, 12:30:56 PM2/5/20
to TiddlyWiki
I use $:/keepstate prefix!

This is different from Tiddlywiki recommendation, but I can remember these are not real tiddlers and I can delete them using AdvancedSearch or Commander.

--Mohammad

PMario

unread,
Feb 5, 2020, 12:52:25 PM2/5/20
to TiddlyWiki
Hi,

The node server uses a config tiddler  https://tiddlywiki.com/#%24%3A%2Fconfig%2FSyncFilter  to sync info back to the server. As you can see the default setting contains:

[is[tiddler]] -[[$:/HistoryList]] -[[$:/Import]] -[[$:/isEncrypted]] -[prefix[$:/status/]] -[prefix[$:/state/]] -[prefix[$:/temp/]]

Just remove the -[prefix[$:/state/]] element from the filter and the state info will be saved back. .. Or use a different name as Mohammad wrote.

-m

Mohammad

unread,
Feb 5, 2020, 1:26:13 PM2/5/20
to TiddlyWiki
Added to TW-Scripts
Reply all
Reply to author
Forward
0 new messages