This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/mixins/buffered-content.js.es6
2019-05-27 10:15:39 +02:00

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");