Created
April 28, 2020 19:07
-
-
Save oradkovsky/96d323f109ef1c06cbe248ec182931fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// declare view model | |
class MyViewModelWithState( | |
private val handle: SavedStateHandle, //always first param btw | |
private val gson: Gson | |
) : ViewModel() { | |
// make use of state bundle as usual | |
} | |
// modify corresponding module | |
val viewModelsModule = module { | |
viewModel { (handle: SavedStateHandle) -> MyViewModelWithState(handle, get()) } | |
} | |
// make use of | |
class MyFragmentWithState : Fragment() { | |
private val myViewModelWithState: MyViewModelWithState by stateViewModel() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment