android / architecture-samples

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
Apache License 2.0
44.49k stars 11.65k forks source link

New sample: MVP-Clean-RxJava-Dagger2 #38

Closed Rainer-Lang closed 1 year ago

NikitaKozlov commented 8 years ago

Is this an open issue for anyone to jump on?

I'd love to implement it.

Rainer-Lang commented 8 years ago

@Kaerdan That would be really great - and YES - this is a sample/issue for the community. So "jump on" :) :+1:

JoseAlcerreca commented 8 years ago

See this new section:

https://github.com/googlesamples/android-architecture/wiki/Unofficial-samples

Rainer-Lang commented 8 years ago

@Kaerdan If you're using a fork, then it's only possible to create an issue in the original repo. @JoseAlcerreca If I want to create an issue only for the repo/fork of Kaerdan, how should I do this? Do you have any suggestions?

JoseAlcerreca commented 8 years ago

Please bear in mind that Rx and dagger2 are being developed. An official Clean+Rx+Dagger2 sample would have to be a combination of the three branches. If you fork Clean and start adding Rx to it, the implementation will be different from what @ErikHellman is working on, probably :), so they would have to be merged afterwards.

But of course if you want to work on it on your own, in your own repo that's fantastic. Development branches can use your implementation as reference too.

Let's not open any more issues @Rainer-Lang, and keep the conversation about it here :+1:

NikitaKozlov commented 8 years ago

@JoseAlcerreca Yeah, I have that in mind, I added Rx in Domain part and it looks really nice. Now, I'm waiting for Rx and Dagger2 branches. At lease the first one, the I can finish mvp-clean-rxjava. It looks like no one is developing Dagger2 branch, probably I should try to implement it, but it is a discussion for another issue.

JoseAlcerreca commented 8 years ago

Cool! Can you share your progress?

We just started development on the Dagger2 branch! I'll assign the issue ASAP.

NikitaKozlov commented 8 years ago

Sure, check this branch: https://github.com/Kaerdan/android-architecture/tree/dev-todo-mvp-clean-rxjava UseCase is now responsible for subscribing and observing on different threads. So Presenter just run a UseCase and subscribe, I think it is a little bit cleaner then asking a Handler to run a UseCase for you, as it is done in todo-mvp-clean. Also concrete UseCase provides Scheduler that in want to use, so the whole concurrency model became more flexible.

Regarding Dagger2, I can write the changes I want to do, you evaluate them and I will implement.

Rainer-Lang commented 8 years ago

@Kaerdan Maybe you could help: At the end of an activity (fragment) (eg user pressed backpress) I have to save data in database and even I have to send data to a server (long running task). How could this be done with MVP-Clean-RxJava-Dagger2? Could you give some hints or make an example for this?

NikitaKozlov commented 8 years ago

@Rainer-Lang I don't really see a problem. You can just create a specific UseCase and use it. I can't recommend anything concrete, because I don't know your intents. One of the pitfalls of your scenario is that no one will be able to process Exception if something will go wrong. Probably it will be better if somebody who launches this activity (fragment), could also send this data to your server. But again I don't know your real intents, so I can only guess. @JoseAlcerreca Sorry for unrelated discussion.

Rainer-Lang commented 8 years ago

@NikitaKozlov 1) When to use this: https://github.com/NikitaKozlov/android-architecture/blob/dev-todo-mvp-clean-rxjava/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/taskdetail/TaskDetailPresenter.java#L73 Thanks.

2) Any plans for MVP-Clean-RxJava-Dagger2?

Rainer-Lang commented 8 years ago

@NikitaKozlov In the example it's used Observable.create(), but there are different known issues. Have a look here: https://artemzin.com/blog/rxjava-defer-execution-of-function-via-fromcallable/ and http://blog.danlew.net/2015/07/23/deferring-observable-code-until-subscription-in-rxjava/

GuillemRoca commented 8 years ago

Any new progress on the sample MVP-Clean-RxJava-Dagger2? Is the sample finished?

BTW, I really like the implementation of @NikitaKozlov, since it reminds me of this repo: https://github.com/android10/Android-CleanArchitecture/tree/core/refactor-project-structure

johnfrey99 commented 8 years ago

+1

clickxu commented 8 years ago

I implemented a MVP-Clean-RxJava-Dagger2 sample too, based on the MVP-Clean sample. Replaced the callbacks with Rxjava & replaced the Injection part by Dagger2. For the UseCases, I considered to keep the possibility to do complicate schedule controls. I wish i could do it based on @NikitaKozlov 's work, but because I just happened to use MVP-Clean-RxJava-Dagger2 in a new product as I mentioned when we met in DevFest Tokyo 2016 @JoseAlcerreca. I want to share my idea here.

tunjid commented 1 year ago

Closing as obsolete.