Open Swaagie opened 10 years ago
@Swaagie there could be some other flag to check im sure right? some post initializing that could be done for those cases?
sure but a developer could potentially include logic in initialize
that is sensitive and should not be executed if the pagelet is disabled or unauthorized, but I'm sure we can think of a way that would do this in a sane manner
On a broader scope, functions like optimize
and traverse
have to be called as well each time if the pagelet is used outside bigpipe. Perhaps a small helper function called standalone
(or similar) would be nice to have
Pagelet.standalone = function standalon() {
var prototype = this.prototype;
prototype.fragement = '{pagelet:template}' // unsure, but will only render the template.
return this.traverse().optimize();
}
Another thought, provide a plugin that adds standalone functionality to pagelets, that should keep the code clean and lean. Per example, rendering child pagelets is also an issue. Calling render
on child pagelets from the parents render
is not possible, as bigpipe would normally have pages iterating through the stack in parallel.
Why would optimize need to be called each time a pagelet is called outside of bigpipe? It only needs to be called once. And i'm +1 on adding a .standone method
with each time I ment, each time any pagelet is used outside bigpipe. In stead of just calling
new Pagelet
someone has to go through all the helper methods as well.
Calling
initialize
by default (if available) would be a nice feature for standalone usability. It would also bring it closer in line with BackboneJS. The only problem is BigPipe currently relies on not callinginitialize
if the Pagelet is not authorized or disabled, see https://github.com/bigpipe/bigpipe/blob/master/page.js#L286-L290