Skip to content
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

MVI ViewModel #59

Merged
merged 17 commits into from Sep 10, 2019
Merged

MVI ViewModel #59

merged 17 commits into from Sep 10, 2019

Conversation

gbasile
Copy link
Member

@gbasile gbasile commented Aug 23, 2019

  • Introduced ViewModel to hold the SearchStore in order to handle the lifecycle consistently.

Now the UI state is preserved after the Activity is destroyed (for example after a rotation)

Some housekeeping:

  • Split the MVIView interface into ViewRender and ActionProvider for better flexibility
  • Created alias for the SearchStore
  • Created interface for the MovieDataSource so we don't rely on a concrete type

* mvi_reducer:
  Remove not needed null check
  Change changes to be a PublishSubject
  Use scan operator to reduce changes to a state
  Change wording to highlight that the query is updated
  add hideLoading and removeResults actions
  Expect SearchMiddleware to hide progress
  Move domain agnostic screen state and screen state changes from domain specific middleware to the reducer
  Rename domain specific changes to domain agnostic screen state changes

# Conflicts:
#	ModelViewIntentSample/search/src/main/java/com/novoda/movies/mvi/search/domain/SearchDependencyProvider.kt
#	ModelViewIntentSample/search/src/main/java/com/novoda/movies/mvi/search/domain/SearchMiddleware.kt
#	ModelViewIntentSample/search/src/main/java/com/novoda/movies/mvi/search/presentation/SearchActivity.kt
#	ModelViewIntentSample/search/src/test/java/com/novoda/movies/mvi/search/domain/SearchMiddlewareTest.kt
@@ -40,17 +40,17 @@ class BaseStore<A, S, C>(
return disposables
}

override fun bind(view: MVIView<A, S>): Disposable {
override fun bind(actionProvider: ActionProvider<A>, viewRender: ViewRender<S>): Disposable {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ViewRenderer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Displayer?

private val reducer: Reducer<S, C>,
private val middlewares: List<Middleware<A, S, C>>,
private val initialValue: S
private val schedulingStrategy: SchedulingStrategy,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do I need to have a consistent indenting with the rest of the project?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you import the novoda code styles from https://github.com/novoda/novoda/tree/master/ide-settings/intellij ?

Copy link
Contributor

@tobiasheine tobiasheine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some questions, otherwise 💯

private val reducer: Reducer<S, C>,
private val middlewares: List<Middleware<A, S, C>>,
private val initialValue: S
private val schedulingStrategy: SchedulingStrategy,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you import the novoda code styles from https://github.com/novoda/novoda/tree/master/ide-settings/intellij ?

@@ -9,8 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".presentation.SearchActivity"
android:screenOrientation="portrait"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

import com.novoda.movies.mvi.search.domain.SearchReducer
import io.reactivex.disposables.Disposable

internal typealias SearchStore = BaseStore<SearchActivity.Action, SearchActivity.State, SearchReducer.Changes>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@tobiasheine tobiasheine merged commit 2737f08 into mvi_reducer Sep 10, 2019
@tobiasheine tobiasheine deleted the mvi_view_model branch September 10, 2019 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants