大佬教程收集整理的这篇文章主要介绍了ember.js – model.save()与model.get(‘store’)的区别.commit(),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// 'this' is the controller this.get('model').save();
和
// 'this' is the controller this.get('model').get('store').commit();
?在我做的小测试中,他们都给了我相同的结果.@R_317_10675@用哪一个?
我调查了第一个,并呼叫
Ds.Model = Ember.object.extend( ... save: function() { this.get('store').scheduleSave(this); var promise = new Ember.RSVp.promise(); this.one('didCommit',this,function() { promise.resolve(this); }); return promise; },
那么问题就变成了,这个.get(‘store’).scheduleSave(this)和this.get(‘store’)之间的主要区别是什么?commit()?
Ds.Store = Ember.object.extend(Ds._Mappable,{ ... scheduleSave: function(record) { get(this,'currenttransaction').add(record); once(this,'flushSavedRecords'); },... /** This method delegates commitTing to the store's implicit transaction. Calling this method is essentially a request to persist any changes to records that were not explicitly added to a transaction. */ commit: function() { get(this,'defaulttransaction').commit(); },
我不知道哪一个更好.我正在倾向于保存(),因为它似乎在商店周围.
(我在github上找不到这些代码,不知道github或者emberjs的amazonaws版本是否是最新版本,这是github上的类似版本:model’s save(),它调用store’s scheduleSave()和store’s commit())
以上是大佬教程为你收集整理的ember.js – model.save()与model.get(‘store’)的区别.commit()全部内容,希望文章能够帮你解决ember.js – model.save()与model.get(‘store’)的区别.commit()所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。