Last active
March 24, 2018 18:48
-
-
Save CesarValiente/ef856e3c801fdb0a648c1889c71ccb45 to your computer and use it in GitHub Desktop.
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
class ItemsControllerView( | |
val itemsViewCallback: WeakReference<ItemsViewCallback>, | |
store: Store, | |
mainThread: ThreadExecutor? = null) | |
: ControllerView(store, mainThread) { | |
fun fetchItems() = | |
store.dispatch(FetchItemsAction()) | |
fun toEditItemScreen(item: Item) = | |
store.dispatch(EditItemScreenAction(item)) | |
fun deleteItem(item: Item) = | |
store.dispatch(DeleteItemAction(item.localId)) | |
override fun handleState(state: State) { | |
when (state.navigation) { | |
Navigation.ITEMS_LIST -> itemsViewCallback.get()?.updateItems(state.itemsListScreen.items) | |
Navigation.EDIT_ITEM -> itemsViewCallback.get()?.goToEditItem() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment