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

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

$
0
0
Hey guys,

I've been toying with the idea of making a base component that includes an app wide can.Map.extend as well as a programmatic interface. The idea here is that the interface would be a singleton can.Map that would be exported, and include publicly accessible methods/states.

The goals here are to:
- Make singleton interfaces that can be synchronously exported, extended, included etc independent of the construction of can.Components.
- Have a global can.Map that all components can bind to, and that is included as the base viewScope. This might have a reference to all interfaces, that's undecided.
- Manage component scope primary through dependency injection, rather than through a crazy amount of attributes
- Avoid relying on can.Component.prototype.scope to do excessive cross binding

Basically, I'm hoping that this will create design patterns that are much more decoupled, and clearer.

It looks like extending can.Component.constructor.Control is not so straightforward unfortunately. The obvious approach was this:

  1. can.Component.extend({
  2.       setup: function() {
  3.             can.Component.setup.apply(this, arguments);
  4.             this.Control = this.Control.extend({
  5.                   _lookup: function( options ) {
  6.                         return [options.scope, options, this.constructor.interface, this.constructor.app, window];
  7.                   }
  8.             })
  9. }, {
  10.       ...
  11. });
Anyway, this isn't even called, and I'm not really too sure to go from here. Any ideas?

Viewing all articles
Browse latest Browse all 3491

Trending Articles