|
|
|
|
|
by jameskilton
4772 days ago
|
|
You can obviously build them wrong and end up with an anti-pattern but no, the Interactor pattern is all about managing how your objects communicate and building code units that are single business cases. In the OP's case, the Comment model shouldn't ever care about Mixpanel, or potentially emailing people that a new comment was posted, that logic can all go in an Interactor, where encapsulation and SRP is not invalidated. Interactors let models handle only what they need to know, and help minimize the coupling between these models. Trying to follow how a feature is implemented in a "typical Rails app" can be a nightmare of View -> Controller -> Model -> lib -> Model -> etc. With this pattern, as long as the interactors are well named, an entire feature can be encapsulated in one object. |
|