Skip to content

DEV: Add a way to observe stores#1307

Merged
ryansolid merged 4 commits intosolidjs:mainfrom
thetarnav:observe-stores
Nov 11, 2022
Merged

DEV: Add a way to observe stores#1307
ryansolid merged 4 commits intosolidjs:mainfrom
thetarnav:observe-stores

Conversation

@thetarnav
Copy link
Contributor

@thetarnav thetarnav commented Oct 23, 2022

  • Adds a dev-only ability to observe stores by adding a new $ON_UPDATE symbol.
  • the dev APIs are bundled into a DEV object, as in the core module (not sure if it should be called STORE_DEV to avoid conflicts, but it's probably whatever)
  • Some typings got cleaned up too (nothing in public APIs though)
  • Added a jsdoc comment to unwrap because why not

Draft because I still want to confirm if this is enough, and maybe add some unit tests.

Adds a dev-only ability to observe stores by adding a new `$ON_UPDATE` symbol.
Add off the dev APIs are bundled into DEV object, as in core module
Some typings got impored too
Added a jsdoc comment to `unwrap` as well
@coveralls
Copy link

coveralls commented Oct 23, 2022

Pull Request Test Coverage Report for Build 3385674394

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 13 of 14 (92.86%) changed or added relevant lines in 3 files are covered.
  • 14 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 89.078%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/solid/store/src/store.ts 11 12 91.67%
Files with Coverage Reduction New Missed Lines %
packages/solid/store/src/store.ts 1 95.38%
packages/solid/src/render/component.ts 13 71.52%
Totals Coverage Status
Change from base Build 3287627654: -0.01%
Covered Lines: 1284
Relevant Lines: 1371

💛 - Coveralls

@thetarnav thetarnav marked this pull request as ready for review November 3, 2022 19:27
@thetarnav
Copy link
Contributor Author

thetarnav commented Nov 3, 2022

Alright, I think this one's ready
I've changed the API to use a global listener, similar to the existing afterUpdate and afterRootCreate hooks.
This will allow for more flexibility and storing updates without pre-patching anything.

@ryansolid ryansolid merged commit 40d6db6 into solidjs:main Nov 11, 2022
@thetarnav thetarnav deleted the observe-stores branch November 11, 2022 09:30
lilybw pushed a commit to lilybw/solid that referenced this pull request Nov 12, 2025
* dev: Add a way to observe stores, export DEV object

Adds a dev-only ability to observe stores by adding a new `$ON_UPDATE` symbol.
Add off the dev APIs are bundled into DEV object, as in core module
Some typings got impored too
Added a jsdoc comment to `unwrap` as well

* Correct changed produce types

* Change the OnStoreNodeUpdate arguments

* Change to global listener for stoes, add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants