Thanks for sharing your work. Routing and state management are really interesting because there are a few different ways they can be handled. I've seen people:
- Define the views directly inside the page - Define views/files in separate files, but load them all as part of your initial page bundle. Instantiate as needed. - Dynamically load views on-demand I don't think there's a single golden answer here. It depends on what you're trying to do. Imo, you should ask yourself what elements in your current package could realistically be used independently. It would appear (without closer study) that <app-router> and <app-route> are somewhat coupled to this element so packaging them together at minimum seem to make sense. How would one interact with <app-views> if not with the other elements? If it's not practical to, it might make sense to bundle it along with the others. You're possibly already aware of these related projects, but there's a Polymer element for Flatiron<https://github.com/PolymerLabs/flatiron-director> and I've also written one <https://github.com/addyosmani/x-route> for handling routing by reacting to `fire`d events on route change. These are more generalized solutions that leave it up to the end developer to figure out how views should appear/be loaded in, however I'm sure there's scope for something more opinionated too! On Friday, 14 March 2014 21:23:26 UTC, Andrew Huth wrote: > > For anyone looking for client-side routing, I've made a collection of > Polymer elements called <app-router> <https://github.com/ahuth/app-router> > . > > To use it, you set up routes (the target attribute specifies where views > will get rendered into): > > <app-router target="#main"> > <app-route to="index">/</app-route> > <app-route to="contact">/contacts/:id</app-route> > </app-router> > > And then you set up views that correspond to the to attributes on the > routes: > > <app-views> > > <template name="index"> > <p>This is the main page</p> > </template> > > > <template name="contact"> > <p>This is contact {{ id }}</p> > </template> > > </app-views> > > Url parameters (in this example 'id') get passed into the views. > > What are your guy/gal's thoughts on this? I'm not a big fan of having the > view definitions on the page. Not sure how else to do it, though. This is > also my first Polymer element, so it may not be as Polymeric as it could > be. Any pointers on that are greatly appreciated. > > Finally, how should this be packaged? It's really a collection of 3 > Polymer elements. Should they be separate, or combined into one package > together? > > <app-router>, <app-route>, and <app-views> are all available at > github.com/ahuth/app-router. Get it while supplies last! > > P.S. This is a rewrite of an earlier post (now deleted) because I didn't > like how I worded it before. > Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/17bbff14-1be8-4e98-ab13-4736641c0f12%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
