DroidKaigi / conference-app-2017

The Official Conference App for DroidKaigi 2017 Tokyo
Apache License 2.0
470 stars 140 forks source link

Use Consumer as callback #334

Closed tomoima525 closed 7 years ago

tomoima525 commented 7 years ago

Issue

Overview (Required)

Pros

Cons

Links

NA

Screenshot

NA

konifar commented 7 years ago

Thanks for interesting idea 👍 Currently, I prefer Callback style. But to be honest, I'm looking for the best way. One of my improvement idea is to inject Callback class to ViewModel. On the other hand, EventBus is also good.

Please let me consider till tonight (JST)! 📝

jmatsu commented 7 years ago

Good idea. Well, how about using Lightweight-Stream-API's Consumer instead of Rx's Consumer? It's not reactive x, but can remove one of cons - Need to wrap with try-catch (which is a bit ugly).

Anyway, I don't know what is the best way... and wanna see @konifar 's opinion. 😄

tomoima525 commented 7 years ago

Thank you for the comments! If you are good to go with this, I'll fix the build(looks like test is failing)

tomoima525 commented 7 years ago

Lightweight-Stream-API's Consumer instead of Rx's Consumer

I never thought about it. Let me try that too.

konifar commented 7 years ago

Sorry for late comment :bowing_man: Finally, I want to adopt original Callback interface style.

To be honest, Consumer style you proposed is good as well :ok_woman: I know the pros but I'm a bit negative for some cons.


1) Reactive style may not be friendly with all Androiders. I think Reactive style is not familiar with all Androiders although Consumer is simple interface. I feel .accept() method is not Intuitive compared with callback.onClickXX(). I would like to keep this project familiar to many Androiders if possible.

2) Consumer#accept(T) method has only one parameter. If I want to pass some parameters, I have to use Pair or create a class.

3) One consumer is responsible for one action. This is cons you mentioned. If ViewModel has 4 click event, it's necessary to add 4 Consumer class to ViewModel, right? I feel a bit complicated.


I think Consumer style is also good! This is almost a matter of taste 🍷

konifar commented 7 years ago

@tomoima525 Sorry, can I close this? 🙇 I really appreciate your suggestion.

tomoima525 commented 7 years ago

@konifar Sorry for the late response. Ok, that's fine with me! Thanks for the comment 😉