Does the JS macros run as a instance of widget?

37 views
Skip to first unread message

Danielo Rodríguez

unread,
Sep 1, 2016, 11:15:54 AM9/1/16
to TiddlyWikiDev
Reviewing the code of the qualify macro I realized it uses the following method

this.getStateQualifier();

This is a method of the widget class. Does this mean that JS macros are executed as widgets? Or they just get a reference to their parent widget on their this?

Regards

Jeremy Ruston

unread,
Sep 1, 2016, 12:38:48 PM9/1/16
to tiddly...@googlegroups.com
Hi Danielo

Reviewing the code of the qualify macro I realized it uses the following method

this.getStateQualifier();

This is a method of the widget class. Does this mean that JS macros are executed as widgets? Or they just get a reference to their parent widget on their this?

Yes, JavaScript macros are invoked with `this` pointing to the widget in whose context the macro is executing.

Best wishes

Jeremy.


Regards

--
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 post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/f1adf9e9-5fe7-47ee-adfd-e38166893705%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Sep 1, 2016, 4:18:18 PM9/1/16
to TiddlyWikiDev
Hello Jeremy,

Thank you for the confirmation. That is very convenient!
Does that mean that we can create javascript macros that decorates their parent widget? Or is it a bad idea?

Jeremy Ruston

unread,
Sep 2, 2016, 3:15:45 AM9/2/16
to tiddly...@googlegroups.com
Hi Danielo

> Does that mean that we can create javascript macros that decorates their parent widget? Or is it a bad idea?

It’s a very, very bad idea. Macros are intended to be idempotent, because they have no control over when they are executed.

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 post to this group, send email to tiddly...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tiddlywikidev.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/50c86d73-438c-422b-8d97-0c4cfb21d271%40googlegroups.com.

Danielo Rodríguez

unread,
Sep 2, 2016, 3:31:37 AM9/2/16
to TiddlyWikiDev
> It’s a very, very bad idea. Macros are intended to be idempotent, because they have no control over when they are executed.

Hahaha, true. Thank you Jeremy
Reply all
Reply to author
Forward
0 new messages