Skip to content

Instantly share code, notes, and snippets.

@abulka
Created May 17, 2020 11:48
Show Gist options
  • Save abulka/909eac8dba8fbafaab31a3947a64d030 to your computer and use it in GitHub Desktop.
Save abulka/909eac8dba8fbafaab31a3947a64d030 to your computer and use it in GitHub Desktop.
TodoMVC-ECS Persistence
class Persistence {
constructor() {
this.todos_data = [] // gather info here
engine.system('reset-save', ['housekeeping'], (entity, { _ }) => {
this.todos_data = []
});
engine.system('gather-todos-for-save', ['data'], (entity, { data }) => {
this.todos_data.push(data)
});
engine.system('save', ['housekeeping'], (entity, { housekeeping }) => {
this.save()
});
save() {
util.store('todos-oo', this.todos_data)
console.log('saved', JSON.stringify(this.todos_data))
}
}
new Persistence()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment