plugin-data-persistence
plugin-data-persistence copied to clipboard
Automatic persistence
Previously posted in the lyra repo:
From an API perspective, if I was creating a persistence package, I would want the ability to persist on each change to the database. It might be nice if a lyra DB was an event emitter for that reason. I could imagine a disk persistence package working like:
const persist = (db, format) => {
saveToDisk(db, format);
db.addEventListener('change', () => {
saveToDisk(db, format);
});
};
That way a user would only need to call persist
once and not manage calling it every time they inserted, removed, etc.