react: add error states and onError callbacks to hooks#58
Open
react: add error states and onError callbacks to hooks#58
onError callbacks to hooks#58Conversation
Changed `TransportProvider` to schedule the transport close as a microtask on unmount, ensuring React's Strict Mode remount cycle cancels the close during development. Updated corresponding test to verify behavior.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useClientTransport now returns { transport, transportError } instead of
throwing when no provider is found or when createClientTransport throws.
A new onError option subscribes to post-construction transport errors
via transport.on('error', ...) with automatic cleanup on unmount.
useView adds an error field to ViewHandle set when loadOlder fails and
cleared on the next successful load. useSend switches to an options-based
API ({ view?, onError? }) with context-fallback view resolution and an
onError callback that fires before re-throwing.
TransportSlot replaces the raw transport in both TransportContext and
NearestTransportContext, holding { transport, error }. TransportProvider
wraps createClientTransport in try/catch so construction errors surface
as transportError in useClientTransport rather than crashing the tree.
Tests cover missing provider, construction failure, onError subscription
and cleanup, loadOlder error/clear cycle, and useSend context fallback.
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.
useClientTransportnow returns{ transport, transportError }instead of throwing when no provider is found or whencreateClientTransportthrows. A new onError option subscribes to post-construction transport errors viatransport.on('error', ...) with automatic cleanup on unmount.useViewadds an error field to ViewHandle set when loadOlder fails and cleared on the next successful load.TransportSlotreplaces the raw transport inTransportContextholding{ transport, error }.TransportProviderwrapscreateClientTransportin try/catch so construction errors surface astransportErrorinuseClientTransportrather than crashing the tree.Tests cover missing provider, construction failure, onError subscription and cleanup, loadOlder error/clear cycle