My first stab at an interactor had state. I was so proud of it, until I read this. I had to think it over, until finally reaching the a-ha! moment a few minutes ago:
My interactor gets results from a web service. Since this is for a mobile app, the service breaks the results into pages. I had the interactor keeping track of the page number, so I could ask it “getFirstPage” to start from page 1, then multiple calls to "getNextPage”. The results were accumulated in the entity.
Moving the page number field from the interactor to the entity changes things. Now the the interactor can actually disappear entirely, and be re-created later. Its lifecycle is no longer an issue, because the entity contains everything needed to continue.
Thanks, Milad (and Uncle Bob of course)!
- Jon