Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call .initialize from constructor #10

Open
Swaagie opened this issue Jun 13, 2014 · 6 comments
Open

Call .initialize from constructor #10

Swaagie opened this issue Jun 13, 2014 · 6 comments

Comments

@Swaagie
Copy link
Member

Swaagie commented Jun 13, 2014

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 calling initialize if the Pagelet is not authorized or disabled, see https://github.com/bigpipe/bigpipe/blob/master/page.js#L286-L290

@jcrugzz
Copy link
Member

jcrugzz commented Jun 13, 2014

@Swaagie there could be some other flag to check im sure right? some post initializing that could be done for those cases?

@Swaagie
Copy link
Member Author

Swaagie commented Jun 13, 2014

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

@Swaagie
Copy link
Member Author

Swaagie commented Jun 19, 2014

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();
}

@Swaagie
Copy link
Member Author

Swaagie commented Jun 19, 2014

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.

@3rd-Eden
Copy link
Member

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

@Swaagie
Copy link
Member Author

Swaagie commented Jun 19, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants