Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : How can I override can.Component's lookup function?

$
0
0
Well, so there are a number of issues with using solely the can attribute approach:
- it doesn't really work all that well when you need to access methods from components that are scattered in the dom tree. Needing to rely on a shared ancestor generally isn't suitable.
- There are cases where it makes sense to have can.Map's defined and exported before your can.Component comes into existence, and this gets really hairy with how can.Component.scope cross binding works.
- Analytics becomes really messy really quickly
- there's no separation between public and private attributes

I like components, I really do, but specifically for single page apps, a lot of times you do have a lot of interdependencies,and it makes more sense to manage those through dependency injection, and only use can.Component attributes for a subset of items when you have a clear hierarchy.

Effectively, in what I'm talking about regarding adding this.constructor.app into the lookup function is similar in principle to the application state object approach that can.route.map is typically used for, only in this case only a subset of properties are represented by routes. If there were a way use can.route.map in this manner, that could work.


Viewing all articles
Browse latest Browse all 3491

Trending Articles