feat(atoms)!: support @atom
node type filter in findAll
and dehydrate
#204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Zedux's "built-in devtools",
ecosystem.findAll
andecosystem.dehydrate
received some upgrades for v2. But hitherto, there was still no good way to make them return only atoms.While #201 made all other node types easier to search for by simply passing an
@
prefix, it did not give atoms an@atom
prefix. I think it still makes sense that these methods should accept@atom
specifically.So: Give both
findAll
anddehydrate
an overload for TS auto completion of the node types. Handle the@atom
string specifically.ecosystem.dehydrate
works exactly the same (but returning an object with dehydrated state values).Breaking Changes
To better support custom ids where you might have to manually filter nodes yourself,
ecosystem.findAll
now returns an array instead of an object keyed by node id.Before, you'd have to use
Object.values
to get the list of returned nodes for manually iterating. That was annoying. Now this API more closely aligns todocument.querySelectorAll
which is probably where the*All
namesake came from.In particular, I did this all the time:
Additonally, making the
@atom
string filter by all atoms is technically a breaking change. It's a best practice to not use the@
character in atom keys/manual id strings so Zedux can add features like this.