You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do a side effect on subscription error using the useSubscription hook.
Current solution:
const{ error }=useSubscription<UserInteraction>(SUBSCRIBE_USER_INTERACTIONS,{onSubscriptionData: ({ subscriptionData })=>{if(subscriptionData.error)// bad typing, never setif(!subscriptionData.data)return;// bad typing, not called if no data
... // side effect on data},});useEffect(()=>{if(!error)return;
... // side effect on error},[error]);
Desired API:
useSubscription<UserInteraction>(SUBSCRIBE_USER_INTERACTIONS,{onSubscriptionData: ({ subscriptionData })=>{
... // side effect on data (with subscriptionData.data! and no subscriptionData.error)},onError: (error: ApolloError!)=>{
... // side effect on error},});
Why:
I think this will make the API more consistent with useQuery and avoid null checks in callbacks, making the code more readable.
The text was updated successfully, but these errors were encountered:
Problem:
Do a side effect on subscription error using the useSubscription hook.
Current solution:
Desired API:
Why:
I think this will make the API more consistent with useQuery and avoid null checks in callbacks, making the code more readable.
The text was updated successfully, but these errors were encountered: