Closed eric-simonton-sama closed 2 years ago
It's a common pattern to combine a RootStore, Persistence and MigrationManager. It would be nice to reduce a little boilerplate. Something like:
RootStore
Persistence
MigrationManager
export class PersistedStore<T extends VersionedObject> extends RootStore<T> { constructor( persistenceKey: string, defaultState: T, migrator: MigrationManager<T>, ) { const persistence = new Persistence<T>(persistenceKey); super(migrator.run(persistence, defaultState)); this.$.subscribe((state) => persistence.put(state)); } }
Added. Will be available in the next release.
It's a common pattern to combine a
RootStore
,Persistence
andMigrationManager
. It would be nice to reduce a little boilerplate. Something like: