feat!: improve injectPromise
- add dataSignal
, initialData
, ZeduxPromise
#222
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, react, stores
Description
Implement all
injectPromise
improvements discussed in #220 for Zedux v2:initialState
toinitialData
dataOnly
with a newdataSignal
that's both returned frominjectPromise
and passed to the promise factory callback function.{ controller, dataSignal }
properties.ZeduxPromise
type that is a drop-in replacement for any atom'sPromise
generic and holds the type ofinjectPromise
's resolveddata
value.useAtomState
anduseAtomValue
to know that the value is resolved when using suspense. Use the newZeduxPromise
type to infer that value.ResolvedStateOf
type helperAlso improve
injectStorePromise
:initialState
toinitialData
ZeduxPromise
types for better hook suspense inference.I didn't update
injectStorePromise
to pass the store as an argument to the promise factory. I figure that's an advanced usage and if people want it, we can just say they need to use the signals-basedinjectPromise
instead.