Created
May 17, 2020 11:48
-
-
Save abulka/909eac8dba8fbafaab31a3947a64d030 to your computer and use it in GitHub Desktop.
TodoMVC-ECS Persistence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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