Thanks to visit codestin.com
Credit goes to github.com

Skip to content

persist should return disposer #20

@agilgur5

Description

@agilgur5

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions