totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

What does self.$query(self, self.callback('index')); do? #625

Closed blaasvaer closed 6 years ago

blaasvaer commented 6 years ago

Following your recommendations I'm trawling through some of the source code for some of your apps. And in this quest I've come upon this in a controller (for the Blog Engine):

self.$query(self, self.callback('index'));

So, in order to try to understand what is going on here, I went into the model to see if I could somehow figure out what this 'index' string was doing in this context. Now, to my own surprise I couldn't figure it out from simply reading the code ...

So, what is the string 'index' doing in this context?

I ask this because the code is complete without comments. Of course apart from comments like these:

        // Refreshes cache
        F.cache.remove('partial-menu');
        F.cache.remove('partial-tags');
        F.cache.remove('partial-latest');
        F.cache.remove('homepage');
BlueMagnificent commented 6 years ago

"index" is meant to be the name of the index view which is located at {blog_engine_root}/themes/default/views/index.html . This is clearly documented in the docs under the FrameworkController section

blaasvaer commented 6 years ago

But VERY hard to pick up from reading the source code from an app. And even though having read the docs I didn't make that connection ... things are to wide apart.

blaasvaer commented 6 years ago

And you have to admit that:

self.$query(self, self.callback('index'));

Is NOT very self explanatory.