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

feat!: improve findAll, ions, and clean up types, properties, and deprecations #212

Merged
merged 2 commits into from
Mar 14, 2025

Conversation

bowheart
Copy link
Collaborator

@affects atoms, stores

Description

There are just a few last things to round up for Zedux v2. Knock them all out.

Add an array overload to ecosystem.findAll that's a shorthand for .findAll({ include: [...mySearchList] }). This is especially useful now that all node types can be returned.

Add a type overload to ecosystem.findAll so editors autocomplete with the new @-prefixed strings by default. This gives some very sleek DX - type ecosystem.findAll(' and you'll see @atom as the first suggestion, which should be the most common. Same goes for the new array overload.

Deprecate the old store-based AtomInstance .setState function property. Prefer .set instead - it does the same thing for store-based atoms, but will make it easier to migrate to signals-based atoms.

Remove the implementation of useAtomSelector. Make it an alias for useAtomValue which now fully supports selectors.

Breaking Changes

Signals-based ions (created via the @zedux/atoms or @zedux/react package's ion factory) now set ttl to zero by default. This was something we almost did years ago with the original spec. I wasn't sure if it was a good default at the time. Now I'm sure. And with the new signals-based ion factory being completely distinct from the old store-based ions, we get a free opportunity to reset. So do it.

The atomDefaults ecosystem config option is gone. The only supported default was ttl and the only other default that made sense was 0. That should no longer be useful since ions are now a built-in way to create ttl: 0 atoms.

The AtomSelectorOrConfig type is renamed to SelectorTemplate.

Stop preventing external nodes (components and event listeners) from being returned by ecosystem.findAll. I've been caught off guard by that behavior multiple times already. So it's bad. ecosystem.findAll can now return every node in the ecosystem.

Rework the AtomInstance _infusedSetter and _set properties to a new x property (short for exportsInfusedSetter). Users shouldn't be using that directly, so obfuscate it. Make it a single getter property that overwrites itself when first used.

@bowheart bowheart merged commit 5c531d9 into master Mar 14, 2025
2 checks passed
@bowheart bowheart deleted the josh/v2-roundup branch March 14, 2025 02:32
@bowheart bowheart mentioned this pull request Mar 14, 2025
53 tasks
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.

1 participant