-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Questions about the architecture #20
Comments
A late response but still.. You can use an Event Bus to push events from the Data Layer and subscribe for these events in a Presenter. |
Regarding your question about mapping – you can resolve this by changing Use Case
Or remove specifying threads in the Use Case and do it entirely in the Presenter:
The choice is entirely up to you, it might depend on what makes more sense in regard to other Use Cases usage in your application. |
I am in a similar situation trying to apply clean architecture principles on a websockets application. I changed my UseCase interface so it only has a request but not a response, just like all the messages on my application, they might trigger or not one or more output messages. Then I injected a dependency on my use cases so they can reply to the presentation layer any time they want. I know this goes against one of the clean architecture principles: dependencies only point to inside layers, never outside, but I think in a websockets application is normal that use cases involves different messages to different clients and this message dispatching is part of the use case logic. You can check out the code on https://github.com/z-stars/FakeAndDrawBack/blob/master/src/main/java/com/fakeanddraw/domain/usecase/AddPlayerToGame.java If you have any suggestion I would be happy to hear :) |
hi dear friends. |
The use cases assume the caller is also the receiver of the data. In most cases, the presenter will call the use case and wait for the result to return for display purposes.
This is mostly true but there are circumstances when it is not what is wanted. For example, my app has chat functionality which uses a websocket. Incoming messages from the server are received in a Socket class in my data module. I could call a use case to deal with it but (a) it seems dirty that such a low level class is using a use and (b) the result of the use case should notify the presenter (if running) about the event.
Any ideas how to deal with this?
Another issue is that by default, the presenter is running on the UI thread so returning data is also on the UI thread (enforced by the use case infrastructure). However, further processing such as domain model to view model can be required and it would be done on the UI thread by default.
Maybe the thread management should remain with the presenter and the use case is oblivious?
The text was updated successfully, but these errors were encountered: