Patrick Wolf
Patrick Wolf

Reputation: 1319

Is there a way to extend prototypes in a more coffee script like manner?

Typically, when using Coffee Script I add methods to Backbone.Marionette.Application like so...

do (Backbone) ->
  _.extend Backbone.Marionette.Application::,
    testMethod: ->
      console.log "I was here"

I was wondering if there is a more "Coffee Script'ish" way to do this. IE with the extends keyword and not using underscores extend.

Upvotes: 2

Views: 442

Answers (1)

Jed Schneider
Jed Schneider

Reputation: 14671

as you have it written, there is no object to extend your app with, but if you want to create an object 'subclassed' you could do something like

class MyApp extends Backbone.Marionette.Application
  testMethod: -> console.log "I was here"

which is basically what @mu is suggesting in his comment.

Upvotes: 2

Related Questions