v1.0.8
Improve async, connection, and permission hooks
This release reworks retry handling across async hooks, adds heartbeat and delay control to WebSocket connections, and fixes permission change tracking.
Features
useQuery— reworked the retry logic soretrynow accepts a function(failureCount, error) => booleanin addition to a boolean or number, letting you decide whether to retry based on the failure count or the error itself.useQuery— added theretryDelayoption to wait a given number of milliseconds before each retry, with the pending retry cancelled onabort(),refetch(), and unmount.useQuery— updatedrefetchIntervalto accept a function returning the next interval, orfalseto stop polling, enabling conditional polling that ends once a condition is met.useWebSocket— reworked the retry logic soretrynow accepts a function(failureCount, event) => booleanin addition to a boolean or number, giving full control over reconnection based on the failure count or the close event.useWebSocket— added theretryDelayoption to wait a given number of milliseconds before each reconnection attempt, with the pending retry cancelled onclose(),open(), and unmount.useWebSocket— added theheartbeatcallback and theheartbeatDelayoption, letting you send a keep-alive message on an interval while the connection is open, using whatever payload your protocol expects.useWebSocket— added theimmediatelyoption to control whether the connection opens on mount, allowing the socket to be opened manually throughopen()when set tofalse.usePermission— added theimmediatelyoption to control whether the permission is queried on mount, allowing the query to be triggered manually throughquery()when set tofalse.
Fixes
usePermission— thechangelistener is now attached to thePermissionStatusobject instead ofwindow, so state updates when the user grants or revokes the permission.
Changes
useWebSocket— renamed theonDisconnectedcallback toonCloseto align with the native WebSocket close event.useWebSocket— renamed thedisconnectedstatus toclosedto align with the native WebSocket close event.usePermission— replaced theenabledoption withimmediately, which only controls the query on mount rather than disabling the hook entirely.