Modified useSubscription
@@ -23,8 +23,8 @@ export function useSubscription({ getCurrentValue, subscribe }) { | |
useEffect(() => { | |
let didUnsubscribe = false; | |
- | |
- const checkForUpdates = () => { | |
+ // NOTICE: value coming from subscription not from getCurrentValue !!! | |
+ const onValue = value => { | |
if (didUnsubscribe) { | |
return; | |
} | |
@@ -35,7 +35,7 @@ export function useSubscription({ getCurrentValue, subscribe }) { | |
) { | |
return prevState; | |
} | |
- const value = getCurrentValue(); | |
+ | |
if (prevState.value === value) { | |
return prevState; | |
} | |
@@ -43,8 +43,8 @@ export function useSubscription({ getCurrentValue, subscribe }) { | |
return { ...prevState, value }; | |
}); | |
}; | |
- const unsubscribe = subscribe(checkForUpdates); | |
- checkForUpdates(); | |
+ const unsubscribe = subscribe(onValue); | |
+ onValue(state.getCurrentValue()); | |
return () => { | |
didUnsubscribe = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment