akre54 / Backbone.NativeView

A reference implementation of a native Backbone.View
MIT License
113 stars 18 forks source link

removed hard dependency on backbone #10

Closed wheresrhys closed 9 years ago

wheresrhys commented 9 years ago

Here (mainly at the bottom of the file) is the best implementation I can think of. It's not ideal because

I don't like the difference in API between the two, but can't think of a better solution.

akre54 commented 9 years ago

So in this version, you'd instantiate with

var NativeView = require('backbone.nativeview')(require('backbone'));

right?

I don't see this as a big advantage.

The problem comes because we're extending the prototype methods, but we also need an instance-specific _domEvents property for each new View instance. We can either have the users extend View.prototype themselves and force them to set _domEvents in initialize, or we can do it for them, but we need a reference to the Backbone object.

Personally I think the current situation is best. But I'm open to arguments.

wheresrhys commented 9 years ago

The advantage is it makes choosing exoskeleton as easy as choosing backbone. If NativeView's main audience is exoskeleton users then it makes sense to do this. Otherwise not so much

On Friday, December 12, 2014, Adam Krebs notifications@github.com wrote:

So in this version, you'd instantiate with

var NativeView = require('backbone.nativeview')(require('backbone'));

right?

I don't see this as a big advantage.

The problem comes because we're extending the prototype methods, but we also need an instance-specific _domEvents property for each new View instance. We can either have the users extend View.prototype themselves and force them to set _domEvents in initialize, or we can do it for them, but we need a reference to the Backbone object.

Personally I think the current situation is best. But I'm open to arguments.

— Reply to this email directly or view it on GitHub https://github.com/akre54/Backbone.NativeView/pull/10#issuecomment-66723418 .

akre54 commented 9 years ago

Exoskeleton is not the main audience. It should work for Backbone first, and if it works for Exoskeleton too, excellent. Exoskeleton is meant to be drop-in. Your build tool is more than capable of handling this.

akre54 commented 9 years ago

Let's leave this in build tool land, barring a better solution.