plugin-data-persistence icon indicating copy to clipboard operation
plugin-data-persistence copied to clipboard

Automatic persistence

Open matthewp opened this issue 2 years ago • 2 comments

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.

matthewp avatar Aug 10 '22 13:08 matthewp