New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create global Alpine.$persist to enable persisting in Alpine.store #2191
Conversation
This right here is a grade A pull request! Only a FOOL would neglect this stunning contribution 💯 |
Great addition! if you want to reset the index.html you can do |
Thanks @MalcolmKnott! Good call @SimoTod - I agree - just do some cleanup on the PR (index.html and any stray extra lines) - then add docs to the Markdown file and we'll be good to goooooo |
48193c4
to
7f41ec0
Compare
@calebporzio Should be ready for review now :) |
<a name="using-alpine-persist-global"></a> | ||
## Using the Alpine.$persist global | ||
|
||
`Alpine.$persist` is exposed golobally so it can be used outside of `x-data` contexts. This is useful to persist data from other sources such as `Alpine.store`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo here @MalcolmKnott:
`Alpine.$persist` is exposed golobally so it can be used outside of `x-data` contexts. This is useful to persist data from other sources such as `Alpine.store`. | |
`Alpine.$persist` is exposed globally so it can be used outside of `x-data` contexts. This is useful to persist data from other sources such as `Alpine.store`. |
7f41ec0
to
19f6d4f
Compare
Thanks @MalcolmKnott! This will be much appreciated by the community! Great work! |
Until now it has been impossible to persist values in an
Alpine.store
This PR extracts the
$persist
magic to a globally accessibleAlpine.$persist
to enable use cases such as:The
$persist
magic is still registered, so this is a non-breaking change for exisiting$persist
users.We've included a test, as well as an index.html that makes it easy to play with the feature. Feel free to remove the index.html before merge. We also fixed a small bug that made rerunning the
persist.spec.js
in the same browser session not work.@DanielCoulbourne says hi.