feat!: improve findAll
, ions, and clean up types, properties, and deprecations
#212
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.
@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 - typeecosystem.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 foruseAtomValue
which now fully supports selectors.Breaking Changes
Signals-based ions (created via the
@zedux/atoms
or@zedux/react
package'sion
factory) now setttl
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-basedion
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 wasttl
and the only other default that made sense was0
. That should no longer be useful since ions are now a built-in way to createttl: 0
atoms.The
AtomSelectorOrConfig
type is renamed toSelectorTemplate
.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 newx
property (short for ex
portsInfusedSetter). Users shouldn't be using that directly, so obfuscate it. Make it a single getter property that overwrites itself when first used.