This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/app/assets/javascripts/discourse/mixins/buffered-content.js.es6

26 lines
616 B
Text
Raw Normal View History

/* global BufferedProxy: true */
export function bufferedProperty(property) {
const mixin = {
buffered: function() {
return Em.ObjectProxy.extend(BufferedProxy).create({
content: this.get(property)
});
}.property(property),
rollbackBuffer: function() {
this.get('buffered').discardBufferedChanges();
},
commitBuffer: function() {
this.get('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');