Skip to content
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

"stores" tab #176

Open
HugoDF opened this issue Mar 10, 2021 · 6 comments
Open

"stores" tab #176

HugoDF opened this issue Mar 10, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@HugoDF
Copy link
Collaborator

HugoDF commented Mar 10, 2021

Devtools can have a "stores" tab

Spruce has a methods (outside of Alpine) for:

("stores" > "spruce" so that we're forward compatible if stores make it into v3)

Originally posted by @HugoDF in #175

@HugoDF HugoDF added the enhancement New feature or request label Mar 10, 2021
@HugoDF
Copy link
Collaborator Author

HugoDF commented Nov 21, 2021

Update: stores are a v3 concept I'm not 100% sure how we can detect/list them if someone else has any ideas feel free to comment.

@ryangjchandler
Copy link
Contributor

There is a private getStores function, could PR and make it public?

@Niush
Copy link

Niush commented Nov 24, 2021

This is my bad solution:

First the extension adds a hidden Alpine initialized field in the body.
It will watch changes in $store and sets $store._devtools_stores with the updated $store data.

<input 
  type="hidden"
  x-title="_devtools_stores"
  x-effect="new_store = { ...$store }; delete new_store._devtools_stores; $store._devtools_stores = new_store"
  x-data="{new_store: null}"
/>

The extension can then show all the stores data from Alpine.store('_devtools_stores').
Any new changes will be updated with x-effect.

From devtools Components page, element with name of _devtools_stores set by x-title can be removed. To hide the above field from showing up.

Alpine.js should not start recursively looking for changes in $store due to the x-effect. I added a console.log in x-effect, and it seems to not be an issue.

@Yahav
Copy link

Yahav commented Apr 4, 2022

@Niush Just tried that, doesn't seem to be working with devtools.
Alpine.store('_devtools_stores') does output the stores but the devtools shows it as empty.
Its a shame.

EDIT:
This seem to work:

<input
    type="hidden"
    x-title="_devtools_stores"
    x-effect="new_store = { ...$store }; delete new_store._devtools_stores; $store._devtools_stores = new_store"
    x-data="{new_store: null}"
/>

@stepanjakl
Copy link

stepanjakl commented May 26, 2022

@Niush @Yahav Your solution works great! However, it would be nice to see global $store(s) natively inside the extension.

@serhumanos
Copy link

yeah! a $store Tab will be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants