Controlling React Effect Execution Based on Status

Does anyone know if it's possible to control an Effect from outside of its execution?

Basically, I have a React app with some status of type 'in-progress' | 'paused' and I want to run an Effect in a loop, when the status is 'in-progress', and pause it when the status is paused.

I've tried using Ref's, Queues etc, but the problem is that changing them always yields an Effect, which doesn't get ran since it just describes the computation

Is there any way to achieve this? Thanks in advance!! 🙂
Was this page helpful?