-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes request #1
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,52 @@ import io.reactivex.android.schedulers.AndroidSchedulers | |
import io.reactivex.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* 💢 Questions | ||
* 🟡 Please, answer on them before moving further and after changes would be made | ||
* 1️⃣ How the configuration changes are handled with Feature (if so)? | ||
* 2️⃣ Can we have MVI using ViewModel or Presenter? | ||
* 3️⃣ Could the race conditions issue happen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* | ||
* IMO, I don't think that the implementation of MVI should be like this. | ||
* The architecture is the very crucial pilar for any app. | ||
* Usually, the implementation is unique for a project as there is no the strict rules how to do it. | ||
* | ||
* 1️⃣ You are relying on the third-party framework which is used presumably in the closed group | ||
* of people. Meaning we are as externals won't know about actual motivation and appetite of | ||
* existed functionality and further updates of the framework. | ||
* Doing so, we explicitly agree with those limitation where we won;t be able to customize it. | ||
* The workarounds would appear. Plus, imagine the owner company is closed, and the framework | ||
* won't be supported. So, your app become outdated pretty fast. 🧐 | ||
* | ||
* 2️⃣ Years ago, I've used Mavericks framework in one of pet projects. But there we decided | ||
* to do so as the Kotlin language wasn't powerful at that moment. But now it's pretty stable with | ||
* having Flows and Channels. Or... it's possible to use Rx instead where we have Observable and | ||
* PublishSubject. It's up to you what to use - Rx or Kotlin, but I would recommend to focus on | ||
* Kotlin 😉 | ||
* | ||
* Material: | ||
* 💠 "Implementation drafts with using only Kotlin" | ||
* https://betterprogramming.pub/all-you-need-for-mvi-is-kotlin-how-to-reduce-without-reducer-5e986856610f | ||
* | ||
* 💢 But... please, check the second material as it would prevent writing a wrong solution | ||
* 💠 "THIS Is the #1 Clean Code Mistake" | ||
* https://www.youtube.com/watch?v=jYetmv0xRRI | ||
* | ||
* 🙏 We shouldn't use base classes in all costs | ||
* | ||
* 3️⃣ Having Feature instead of ViewModel/Presenter makes confuse 😥. Usually, we are as an Android | ||
* engineers prefer work with the intermediate presentation component - ViewModel or Presenter only. | ||
* I don't think it's a good thing to keep alive as it increases the learning curve. | ||
* We should keep things as simple as possible. So, we can-should have VM or Presenter with | ||
* the implementation of MVI concept. Try to consider it as an upgrade/level-up of VM or Presenter. | ||
* | ||
* Material: | ||
* 💠 Not theoretical comparison of MVVM and MVI | ||
* https://www.youtube.com/watch?v=cnU2zMnmmpg | ||
* | ||
* 4️⃣ Regarding the naming convention we should stick to Event, State, SideEffect (if needed) | ||
*/ | ||
class MyMealsFeature @Inject constructor( | ||
initialState: State, | ||
actor: Actor<State, Wish, Effect>, | ||
|
@@ -19,7 +65,11 @@ class MyMealsFeature @Inject constructor( | |
MyMealsFeature.State, | ||
Nothing>(initialState = initialState, actor = actor, reducer = reducer) { | ||
|
||
// Should be extracted to outside 😉 | ||
// The same for Wish, Effect, etc. | ||
data class State( | ||
// State should expose UI models or primitive types. | ||
// Or UI model that holds the domain model | ||
val recentMeals: List<Meal>? = null, | ||
val favouriteMeals: List<Meal>? = null | ||
) | ||
|
@@ -34,6 +84,8 @@ class MyMealsFeature @Inject constructor( | |
data class LoadedFavouriteMeals(val meals: List<Meal>) : Effect() | ||
} | ||
|
||
// Wish and Effect types seem are the same from the syntax sense at least. | ||
// In other words, kinda of duplication that causes the complexity. | ||
class ActorImpl( | ||
private val mealsRepository: MealsRepository | ||
) : Actor<State, Wish, Effect> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/src/main/java/com/hifeful/mealmania/presentation/myMeals/MyMealsUiEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I knew that but decided to not duplicate classes for such a simple application. Of course in the multi-modular architecture, it's mandatory.