2014-09-25 11:32:08 -04:00
|
|
|
/* global BufferedProxy: true */
|
2015-07-10 12:28:56 -04:00
|
|
|
export function bufferedProperty(property) {
|
2015-11-12 16:08:19 -05:00
|
|
|
const mixin = {
|
2015-07-10 12:28:56 -04:00
|
|
|
buffered: function() {
|
|
|
|
return Em.ObjectProxy.extend(BufferedProxy).create({
|
|
|
|
content: this.get(property)
|
|
|
|
});
|
|
|
|
}.property(property),
|
2014-09-25 11:32:08 -04:00
|
|
|
|
2015-07-10 12:28:56 -04:00
|
|
|
rollbackBuffer: function() {
|
|
|
|
this.get('buffered').discardBufferedChanges();
|
|
|
|
},
|
2014-09-25 11:32:08 -04:00
|
|
|
|
2015-07-10 12:28:56 -04:00
|
|
|
commitBuffer: function() {
|
|
|
|
this.get('buffered').applyBufferedChanges();
|
|
|
|
}
|
2015-11-12 16:08:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// It's a good idea to null out fields when declaring objects
|
|
|
|
mixin.property = null;
|
|
|
|
|
|
|
|
return Ember.Mixin.create(mixin);
|
2015-07-10 12:28:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default bufferedProperty('content');
|