2016-03-27 14:57:22 +02:00
|
|
|
'use strict';
|
|
|
|
|
2017-01-31 07:50:28 +01:00
|
|
|
const Backbone = require('backbone');
|
|
|
|
const SettingsStore = require('../comp/settings-store');
|
2016-03-27 14:57:22 +02:00
|
|
|
|
2017-01-31 07:50:28 +01:00
|
|
|
const RuntimeDataModel = Backbone.Model.extend({
|
2016-03-27 14:57:22 +02:00
|
|
|
defaults: {},
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
this.listenTo(this, 'change', this.save);
|
|
|
|
},
|
|
|
|
|
|
|
|
load: function() {
|
2017-02-04 19:31:26 +01:00
|
|
|
SettingsStore.load('runtime-data', this.onLoaded.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoaded: function(data) {
|
2016-03-27 14:57:22 +02:00
|
|
|
if (data) {
|
|
|
|
this.set(data, {silent: true});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
save: function() {
|
|
|
|
SettingsStore.save('runtime-data', this.attributes);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
RuntimeDataModel.instance = new RuntimeDataModel();
|
|
|
|
|
|
|
|
module.exports = RuntimeDataModel;
|