Understanding Handling Observable in Interactions Below the Usecase Layer

Asked 5 months ago, Updated 5 months ago, 18 views

I am involved in the design and development of Android applications, but based on the assumption of developing Android applications,
I have a question about the design.

We would like to hear your opinion,
When using DDD or clean architecture in Android app development, RxJava's Observable is often used for Presenter <-> UseCase.
Business logic, etc. are handled in the background and are now responsible for returning results to the UI.

   .subscribeOn (backgroundScheduler)

So far, this pattern is common elsewhere, but
You see this pattern extending to interaction in the UserCase<->Domain,Domain<->Infra layer.
I understand that Observable is a "library that eliminates many of the troubles associated with asynchronous processing", so if you look at this description, it looks like "asynchronous messaging is recommended even below the UseCase layer".

Observable is certainly useful, but I personally believe that bringing asynchronous to business logic can complicate the code, so I try to write the lower layer of UseCase in synchronous processing.
In some cases, it is necessary to use asynchronous due to restrictions and requirements.
Without them, you can also see statements that recommend using Observable.

After considering the advantages of Observable, I came up with the following:

Personally interpreting this, isn't the treatment of Observable at the bottom of the UseCase layer intended to respond/monitor asynchronous processing, but to benefit from (2)(3)?
I came to the conclusion that ...

I would like to ask your opinion on why you are using Observable.
I would appreciate it if you could give me your opinion on asynchronous processing at the bottom of the UseCase layer as well.

android domain-driven-design reactive-programming

2022-09-30 14:14

1 Answers

I am also designing and developing Android.
It may not be very helpful, but I have had similar questions, so
Let me share my thoughts.

I have used the Observable layer below UseCase and I have not used it.

First of all, the reason why I used it in the lower layer is

Next, although not what you are asking,
The reason why I didn't use it in the lower layer is

In the latter case, the layered architecture of DDD was adopted, so

not really UseCase The ApplicationService in the Application layer failed to convert to Observable.

These are the reasons why I used it below UseCase and why I didn't.

By the way, I'm sorry if you know
Android-CleanArchitecture has also been discussed.

2022-09-30 14:14

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.