class TheModel extends Backbone.Model
foo:
#bar
Entity = new TheModel(#pass in attributes)
Can I then extend Entity and maintain the models attributes/state?
class User extends Entity
foo:
super
#more
EDIT:
class Entity extends Backbone.Model
initialize: (options) ->
@_events options
_events: (options) ->
entity.bind 'foo'
class Entity1 extends Entity
_events: (options) ->
super options
entity.bind 'bar'
class Entity2 extends Entity
_events: (options) ->
super options
entity.bind 'baz'
#a new entity arrives, we don't know if he is type one or two yet so he is...
entity = new Entity
#now we find out he is type 2
entity = new Entity2(entity.attributes)
No. Having a class extend an object (rather than a function) doesn’t make sense. If you tried to instantiate your
Userclass, you’d get the errorIf you want to override the
foomethod onEntity, you should do so directly, though note that thesupersyntax won’t work. Instead, you should write