Last active
August 29, 2015 14:00
-
-
Save qrg/11319317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mixin --------------------------------------------- | |
mixins = require 'mixins' | |
module.exports = mixins.foo = | |
bindings: | |
'.js-mixin-binding-target': 'someModelAttr' | |
mixinMethod: -> | |
# do something | |
# view --------------------------------------------- | |
View = require 'views/base/view' | |
mixins = require 'mixins' | |
module.exports = class BarView extends View | |
_(@prototype).extend mixins.foo | |
_(@prototype.bindings).extend | |
'.js-view-binding-target': 'otherModelAttr' | |
viewMethod: -> | |
# do something |
_.deepExtend というのがあった
# view ---------------------------------------------
View = require 'views/base/view'
mixins = require 'mixins'
module.exports = class BarView extends View
bindings:
'.js-view-binding-target': 'otherModelAttr'
_(@prototype).deepExtend mixins.foo
viewMethod: ->
# do something
$.extend true, @prototype, mixins.foo
でもやってることは同じ?
とおもったら、 _.deepExtend が利用できるのは、powmedia/backbone-deep-model を入れてるせいだった
backbone-deep-model/lib/underscore.mixin.deepExtend.js at master · powmedia/backbone-deep-model
backbone-deep-model を将来的に使わなくなって uninstall したときに動かなくなるのも困るので、結局 jquery の extend を利用することにした
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
deep copy の方面をあたるべきぽい