Hi, today I gave a talk in Droidcon Spain about Clean architecture, quite similar to the Salamanca but with some fixes and improvements over this implementation. Now I don’t use a bus for this architecture anymore and I reduced the boilerplate.
The new implementation of the invoker is based on Futures and promises Java API. It uses the Java Executor to submit FutureTasks of the Java API. With this new implementation, we can have a Future> when invoking some interactor and do the progress in the same thread or cancel the interactor using this two future’s methods.
The Interactor Output is an interface with 3 methods onResult, onError and onCancel. This can be a little verbose to implement if every interactor is requesting this 3 methods so I created an Annotation Processor for generating implementations of InteractorOutput simply using @Output, @OnResult, @OnError and @OnCancel.
No more thread hell
When using the bus I used a method to return all the results in the main thread, but now we don’t have the bus so I rethought my strategy and I opted for a different solution. When the presenter calls getView().X now uses a decorated implementation that handles the view call and uses the main thread. This is created by another annotation processor.
I will explain this three points with different posts in detail on the next days some so stay tuned.
The code is available now on Github