Skip to content

Instantly share code, notes, and snippets.

@haroldadmin
Created June 1, 2019 04:10
Show Gist options
  • Save haroldadmin/d79a8025540a2a6a20281d54756cb611 to your computer and use it in GitHub Desktop.
Save haroldadmin/d79a8025540a2a6a20281d54756cb611 to your computer and use it in GitHub Desktop.

Revisions

  1. haroldadmin created this gist Jun 1, 2019.
    7 changes: 7 additions & 0 deletions withStateSuspend.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    protected suspend fun withStateSuspend(block: suspend (state: S) -> Unit ) {
    withState { state ->
    viewModelScope.launch {
    block(state)
    }
    }
    }