I've recently stumbled upon Clean Architecture, by Uncle Bob, and I'm curious to know whether Interactors can execute other Interactors.
For example, these are my Interactors as of now: getEmptyAlbums, getOtherAlbums. Both have Callbacks that return with a list of Albums (An ArrayList of an Album model) respectively.
Am I allowed to have an Interactor called getAllAlbums that executes the previous two Interactors within it's run block?
@Override public void run() { getEmptyAlbums.execute(); } void onEmptyAlbumsReceived(ArrayList<Album albums){ getOtherAlbums.execute; } void onOtherAlbumsReceived(ArrayList<Album albums){ mMainThread.post(new Runnable() { callback.onAlbumsReceived(albums); } });
Interactors: little, reusable chunks of code that abstract logic from presenters while simplifying your app and making future changes effortless. But are they all they're cracked up to be? Before I go on, the interactor pattern has a number of variations in Android.
Clean architecture vs. The logical layers of this style are as follows: Presentation layer ( accounts for the presentation to the user) Business logic layer (contains the business rules) Data access layer (processes the communication with the database)
Interactor is a class which separates Domain Layer from Presentation Layer. In simple words it provides way to write business logic separately than code which is used for manipulate UI (by binding data to UI/ animate / navigation). So Interactor is mediator between Presenter/ViewModel and Repository pattern.
I have been pondering the same thing and after finding very little on the subject, I have come to the conclusion "Yes" it is probably the best option.
my reasoning as follows:
To preserve single responsibility, I would consider limiting aggregating use-cases to do only that, i.e. executing those use cases and doing any final transformations.
Given the age of this question, I'd be interested to know which way you went with this and issues you encountered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With