Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modify subscribe in useSource not to allow getCurrentValue in ef… (#523)

This stops us from creating temporary subscriptions when useSubscription
calls getCurrentValue in useEffect. This may happen because React first
checks whether it has missed any values.

Due to this change we may miss changed values, but this shouldn't be
an issue, because `subscribe` is pretty reliable in returning up-to-date
state.

authored by

Phil Plückthun and committed by
GitHub
3b459f14 14a31ed8

+6 -8
+6 -8
src/hooks/useSource.ts
··· 35 35 return currentValue; 36 36 }, 37 37 subscribe(onValue: () => void): Unsubscribe { 38 - return pipe( 39 - updateValue, 40 - subscribe(() => { 41 - hasUpdate = true; 42 - onValue(); 43 - hasUpdate = false; 44 - }) 45 - ).unsubscribe as Unsubscribe; 38 + hasUpdate = true; 39 + const { unsubscribe } = pipe(updateValue, subscribe(onValue)); 40 + return () => { 41 + unsubscribe(); 42 + hasUpdate = false; 43 + }; 46 44 }, 47 45 }; 48 46 }, [source])