I want to await for changes in shared state and act on those, so:
function Foo() {
const [bar, setBar] = useContext(myContext)
const someHandler = async () => {
doSomething()
while(true) {
await stateDidChange(bar)
doSomething()
}
}
// apply someHandler to a button, etc
}
(yes, I know I can achieve something similar by removing the while loop and waiting for re-render - humor me :))
Is there a function like stateDidChange(someRandomState)
as used above, or can one be generically written?