Implementing a Cancelable Function with Effect

I have this function, and 'execute' can be called externally, so i want to make sure that only previous execute should be cancelled and latest should be there, how can i do this with effect?, is there any effect way to do this?
Was this page helpful?