Jeremy,
... have the browser create a tiddler with some flags that gets synced to
> the server. The serverside code picks up the tiddler (by searching for the
> same flags), and then performs some operation, putting the results back in
> the same tiddler.
>
So far it works so that the server receives the query and executes the
change, but how can I "upload" the changes? On the file system I can see
that the tiddler has changed, but how can I update it in the browser? There
I still see the query, not the response.
Example code:
* Create a new directory and cd into it
* `npm init && npm install --save tiddlywiki`
* Create `index.js` with this content:
// Start TiddlyWiki
var $tw = require('tiddlywiki').TiddlyWiki();
$tw.boot.argv = ['gui', '--listen'];
$tw.boot.boot(function() {});
$tw.wiki.addEventListener("change", function (changedTiddlers) {
if (!"$:/communicate-with-server" in changedTiddlers) return;
var tiddler = $tw.wiki.getTiddler("$:/communicate-with-server");
if (!tiddler || (tiddler.fields["sender"] === "server")) return;
console.log("Query got from browser");
var query = tiddler.fields.text;
var response = $tw.wiki.getModificationFields();
response["sender"] = "server";
// Parse query...
console.log("Original query:" + query);
response.text = query.toUpperCase();
$tw.wiki.addTiddler(new $tw.Tiddler(tiddler,response));
});
* `node index.js`
* Create "$:/communicate-with-server" and write something in it
When you save it, it notifies you in the terminal (where Node is running)
that it has received a request from the browser and executes the change
(capitalizing the text), saves the file, but the browser knows nothing
about it: it still does shows the version in memory. (If you want to send a
request again, make sure the "sender" field is cleared)
How do I get the browser to read the file system change? And how do I tell
the browser when the change was made (so I don't have to use a timer after
I send the request)?
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/17d5d753-6874-4a88-936e-eabf03db3a39%40googlegroups.com.