Persistent $store values #1506
Replies: 4 comments 24 replies
-
Hey @joshuahamilton, Spruce author here. I don't know if there's any plans to support persisted stores, although I am tempted to extract this out into a separate package that would be powered by |
Beta Was this translation helpful? Give feedback.
-
I'd like to offer this behavior by combining the existing stores API with the new (unreleased) "$persist" plugin. Let's talk potential APIs. This is the first one that comes to mind: // Persist a single value
Alpine.store('counter', {
count: Alpine.$persist(0),
}) // Persist the whole store
Alpine.store('counter', Alpine.$persist({
count: 0,
})) Not sure this is even something Alpine should tackle. Wondering how high the demand is for persistent stores. |
Beta Was this translation helpful? Give feedback.
-
I'd prefer a solution that allows you to optionally pass in your set and get methods for persistence since I sometimes use something other than localStorage. |
Beta Was this translation helpful? Give feedback.
-
hi |
Beta Was this translation helpful? Give feedback.
-
Apologies if the functionality is there and I'm too dumb to read the docs good, but is there a plan to support persistent storage of
$store
ed values? For context, my project was leveragingSpruce.store()
, but with v3 of Alpine the author has put Spruce into 2.x maintenance mode. Unfortunately, as far as I can tell, Alpine has not implemented local storage as an option, a key feature of Spruce, so my project is crippled a bit as a result.I've been exploring making my own implementation leveraging
Alpine.magic
functions,Alpine.reactive
, and nbubna/store but honestly this is a bit beyond my depth.Thanks, and congrats on the milestone. I've been really happy with Alpine the last couple months I've been working with it.
Beta Was this translation helpful? Give feedback.
All reactions