It depends on what you plugin does. In each tiddler you  need to put what 
type of module the javascript is so that tiddlywiki can load it at the 
correct time - generally try and copy what others have done.

$tw is alway visible - it is a global variable.

If you have a particular functionality then I may be able to be more 
specific, you can experiment and see what works.



On Tuesday, March 22, 2016 at 6:22:32 PM UTC, Alain Dutech wrote:
>
> Thanks BJ.
>
> I have looked a bit at boot.js and various startup modules. It is a bit 
> more clear (especially how $tw is created and populated, but not perfrect. 
> Still, I cannot say when the $tw can be used. 
>
> Specifically, if a create a new module with the classical
> `(function(){ ... `
>
> I will not be able to use `$tw.utils`. What should I do to "see" $tw ? 
> If I call my module from a Widget, I could pass my module the $tw variable 
> ? Other ways ?
>
> And, to go back to filter.js
> For example, $tw is used inside the fonction
> exports.compileFilter = function(filterString) {
>
> Is it because filters.js is loaded through $tw.modules.applyMethods() that 
> $tw is in its scope ?
>
> Alain
>
>
>
> On Sun, Mar 20, 2016 at 8:22 PM, BJ <[email protected] <javascript:>> 
> wrote:
>
>> HI Alain,
>> the modular structure of tiddlywiki is more extensive that 'require'.
>>
>> There is some documentation here
>>
>> tiddlywiki.com/dev. <http://tiddlywiki.com/dev>
>>
>> but mostly you can read the code! but ask questions when you get stuck.
>>
>> The $tw structure is populated in a number of step during the start up. 
>> It is defined at the begin of the boot and some basic functionality is 
>> added to it in boot.js. Alot of extra stuff in added to it in 
>>
>> $:/core/modules/startup/load-modules.js
>>
>> javascipt modules in tiddlywiki can have a module-type that allow them to 
>> be  add to $tw thru $tw.modules.applyMethods(). (including the filter 
>> functions)
>>
>> Some places use 'this' instead of $tw, may be for some future expansion 
>> of tw?
>>
>> all the best
>>
>> BJ
>>
>>
>> On Sunday, March 20, 2016 at 5:16:22 PM UTC, Alain Dutech wrote:
>>>
>>>
>>> Hi,
>>> this must be a bunch of stupid questions but I'm still learning the 
>>> logic of javascript.
>>>
>>> 1) when is the global $tw variable available?
>>>   - what "module" are required for it to be available ?
>>>   - does it become available after  
>>> `require("$:/core/modules/widgets/widget.js");` ? Why ?
>>>   - how come $tw can be used in the filter.js module ? as show below
>>>
>>> exports.getFilterOperators = function() {
>>>     if(!this.filterOperators) {
>>>         $tw.Wiki.prototype.filterOperators = {};
>>>         $tw.modules.applyMethods("filteroperator",this.filterOperators);
>>>     }
>>>     return this.filterOperators;
>>> };
>>>
>>> Is it because getFilterOperators is defined inside "exports" ??
>>>  
>>> 2) To use the filter API, and in particular the filterTiddler function 
>>> defined in filters.js (see below), must I "require" filter.js, or 
>>> widget.js, or wiki.js or ???
>>>
>>> exports.filterTiddlers = function(filterString,widget,source) {
>>>     var fn = this.compileFilter(filterString);
>>>     return fn.call(this,source,widget);
>>> };
>>>
>>> 3) the `this.wiki` of Widgets is initialized through the option 
>>> parameters in the Widget constructor.
>>> so all the function exported by wiki.js are available through this.wiki ?
>>>
>>> 4) Is there like a list of "public" function available through $tw, 
>>> $tw.utils and this.wiki ? I am trying to guess by reading through the 
>>> various *.js modules, but I'm my knowledge of JS make this task a bit 
>>> tedious...
>>>
>>> Thanks for any hint or explanations or info.
>>> Alain
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "TiddlyWikiDev" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/tiddlywikidev/Ul3ezJU98QA/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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/5fcc3488-48af-4159-b267-f3a62fcf8a69%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/tiddlywikidev/5fcc3488-48af-4159-b267-f3a62fcf8a69%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 post to this group, send email to [email protected].
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/215cb573-7850-41ca-8cc5-99c49095c17e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to