fix: useRive* hooks start undefined, value delivered via listener#184
Draft
fix: useRive* hooks start undefined, value delivered via listener#184
Conversation
…patibility Add async equivalents for all sync ViewModel/RiveFile methods (createInstanceByNameAsync, getValueAsync, viewModelByNameAsync, etc.) and mark legacy sync methods as @deprecated. Native implementations wrap sync calls in Promise.async on both iOS and Android.
Initial value is no longer read synchronously from property.value. Instead the hook always starts as undefined and receives the current value through the listener's first emission. This unifies the startup shape across legacy (sync emit) and experimental (async valueStream) backends, so consumers always handle the loading state. The setter callback now uses React state for updater functions instead of reading property.value synchronously.
4d3d3a6 to
54c186e
Compare
Legacy addListener does NOT emit on subscribe — only on changes. Without this, hooks stayed undefined forever if the value never changed. Now the effect reads property.value synchronously when subscribing, then the listener handles subsequent updates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #183. diff
useRiveNumber/String/Boolean/Color/Enum hooks now always start as
undefinedand receive the current value through the listener's first emission, instead of readingproperty.valuesynchronously on mount. This unifies startup behavior across legacy and experimental backends.Consumers should guard renders:
value !== undefined ? value.toFixed(2) : '…'