Skip to content

Instantly share code, notes, and snippets.

@akshaybhange
Last active July 26, 2019 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshaybhange/08c954fd299ab2be5f42cf81d4dee0c0 to your computer and use it in GitHub Desktop.
Save akshaybhange/08c954fd299ab2be5f42cf81d4dee0c0 to your computer and use it in GitHub Desktop.
how to move your logic from view to viewmodel
//this is wrong
//writing logic for filtering items in your Fragmet 
var filterList = simpleList.filter { it%2 == 0 }
//this is correct
//function created for it in your ViewModel
fun getEvenNumbers(simpleList : List<Int>):List<Int> {
return simpleList.filter { it%2 == 0 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment