Skip to content
Snippets Groups Projects
Commit ba3dbf34 authored by Mathis Neumann's avatar Mathis Neumann
Browse files

listen to changelog stream and automatically parse and add them into the Ember Data store

parent f541224e
No related branches found
No related tags found
No related merge requests found
import Ember from 'ember';
export default Ember.Service.extend({
store: Ember.inject.service(),
parse(changelog) {
this.debug('store', this.get('store'));
this.debug('parsing changelog', changelog);
const data = changelog.data;
const store = this.get('store');
const normalized = store.normalize('node', data); // using application serializer
this.debug('normalized', normalized);
store.push(normalized);
}
});
\ No newline at end of file
......@@ -2,6 +2,7 @@ import Ember from 'ember';
export default Ember.Service.extend({
shouldClose: false,
changelogParser: Ember.inject.service(),
init() {
this._super(...arguments);
this.debug('session', this.get('systemId'));
......@@ -51,7 +52,7 @@ export default Ember.Service.extend({
this.debug('new changelog received', changelogJson);
try {
const changelog = JSON.parse(changelogJson);
this.debug('changelog converted', changelog);
this.get('changelogParser').parse(changelog);
} catch (e) {
console.error('could not parse changelog json', e, changelogJson);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment