Skip to content

Instantly share code, notes, and snippets.

@charlag
Created September 10, 2017 15:07
Show Gist options
  • Save charlag/4d069d4a1411ee86b7e7e3c81a433c3d to your computer and use it in GitHub Desktop.
Save charlag/4d069d4a1411ee86b7e7e3c81a433c3d to your computer and use it in GitHub Desktop.
private val viewStateEffect = Transformer<State, Event, Event.ViewStateEvent> { upstream ->
upstream.distinctUntilChanged { old, new -> old.second == new.second }
.map { (_, state, _) ->
val viewState = state.todos.map {
TodoViewData(it.id, it.text, it.completed)
}
.sortedBy { it.completed }
Event.ViewStateEvent(viewState)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment