2013-03-19 43 views

回答

0

更新:

看看这个博客帖子:http://rmosolgo.github.io/blog/2014/03/19/batman-dot-model-lifecycle-callbacks/

希望它能帮助!


我只是看着这个自己。我发现一个很好的办法让这个功能是一旦它被修建提上记录监听器,以模型的生命周期的优势:

class App.Thing extends Batman.Model 
    constructor: -> 
    super # instantiates the record 

    @get('lifecycle').onEnter 'save', => 
     console.log('about to save!') 

    @get('lifecycle').onExit 'save', => 
     console.log('just saved!') 

    @ # return the record 

这不是记录太多,但你可以看到the tests描述的完整记录生命周期(步骤名称,顺序等等!)!