agilgur5 / agilgur5/mst-persist

`persist` should return disposer

Abierto
#20 0 comentarios 1 reacción 0 asignados Ver en GitHub
kind: feature
Lenguaje dominante
TypeScript
Estrellas
86
Forks
14
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

This is part feature, as it introduces new functionality, and part bug, as really it should have always returned a disposer to begin with.

Without a disposer there is, well, no way to dispose of the `onSnapshot` listener, and therefore no way to pause / stop persistence. A `disposer` is returned from [`onSnapshot`](https://github.com/mobxjs/mobx-state-tree/blob/master/docs/API/README.md#onsnapshot) and should be returned by `persist`. As it currently returns a Promise, it should be within that Promise.

While the current Promise returns the snapshot of persisted data, that's actually undocumented behavior as you can get the snapshot directly from the store anyway. It's not particularly useful behavior as a result; when I originally created this, I just figured I'd return something rather than nothing/void.
So while this would be breaking, I think it should be ok to change without a major as I don't believe anyone's using that functionality (though no one's requested this functionality either, as it's a fairly uncommon need).
As this is part feature and part breaking change, leaning toward releasing this change as a minor (and breaking changes in minors are ok in semver for 0.x releases) rather than a patch.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.