26 lines
605 B
JavaScript
26 lines
605 B
JavaScript
/* global BufferedProxy: true */
|
|
export function bufferedProperty(property) {
|
|
const mixin = {
|
|
buffered: function() {
|
|
return Ember.ObjectProxy.extend(BufferedProxy).create({
|
|
content: this.get(property)
|
|
});
|
|
}.property(property),
|
|
|
|
rollbackBuffer: function() {
|
|
this.buffered.discardBufferedChanges();
|
|
},
|
|
|
|
commitBuffer: function() {
|
|
this.buffered.applyBufferedChanges();
|
|
}
|
|
};
|
|
|
|
// It's a good idea to null out fields when declaring objects
|
|
mixin.property = null;
|
|
|
|
return Ember.Mixin.create(mixin);
|
|
}
|
|
|
|
export default bufferedProperty("content");
|